CSS Parts (::part)
Pierce the Shadow DOM to customize sidebars, action buttons, and containers with gradients and backdrop filters. Explore CSS Parts Guide
RapiDoc features a streamlined, token-driven theming architecture inspired by modern design systems. Built as a standard W3C Web Component, its markup and stylesheets reside inside an encapsulated Shadow DOM, ensuring that external application styles never clash with your API documentation.
RapiDoc consolidates visual customization into four primary attributes:
<rapi-doc spec-url="https://api.example.com/openapi.json" theme="emerald" color-scheme="dark" radius="md" scale="default" nav-item-spacing="default"></rapi-doc>| Attribute | Allowed Values | Default | Description |
|---|---|---|---|
theme |
amber, blue, graphite, modern, emerald, violet, rose, slate, default, or any #hex code |
"amber" |
Color palette preset matching shadcn/ui color tokens, or a custom brand color hex code. |
color-scheme |
dark, light, system |
"dark" |
Base surface mode. "system" automatically tracks the user’s OS prefers-color-scheme preference. |
radius |
none, sm, md, lg, full |
"sm" |
Corner radius scale applied across cards, buttons, badges, inputs, and modal dialogs. |
scale |
sm, default, lg |
"default" |
Proportional scale factor for UI base dimensions, body typography, code blocks, and sidebar width. |
nav-item-spacing |
compact, default, relaxed |
"default" |
Vertical density and padding of sidebar navigation links, decoupled from font size scaling. |
load-fonts |
true, false |
"true" |
When set to "false", prevents automatic loading of Open Sans from Google Fonts (for air-gapped or offline networks). |
You can supply your corporate brand color directly into the theme attribute without writing external CSS:
<rapi-doc spec-url="https://api.example.com/openapi.json" theme="#2563eb" color-scheme="dark" radius="md"></rapi-doc>When a hex color is supplied:
--primary to your exact hex color.--ring to match the brand color.--primary-foreground: #000000; if dark, it sets --primary-foreground: #ffffff. This guarantees accessible, high-contrast button and badge labels automatically.radius)The radius attribute controls roundness across the entire documentation interface:
radius="none": Sharp 0px corners for brutalist or dense terminal-style layouts.radius="sm" (default): Subtle 4px (0.25rem) radius for clean, modern interfaces.radius="md": Balanced 6px (0.375rem) radius matching contemporary web apps.radius="lg": Pronounced 8px (0.5rem) radius for playful, consumer-facing portals.radius="full": Pill-shaped buttons and inputs (9999px) with rounded 8px cards.scale)The scale attribute controls typography, base sizing, and proportional margins:
scale="sm": Compact scale (13px base font, 17rem sidebar width). Ideal for embedded documentation cards or split-screen consoles.scale="default" (default): Standard desktop scale (14px base font, 18.75rem sidebar width). Optimal for full-page documentation portals.scale="lg": Generous scale (16px base font, 21rem sidebar width). Optimal for large monitors, accessibility compliance, and presentations.nav-item-spacing)Adjust sidebar link density without altering the global font size:
nav-item-spacing="compact": 5px vertical padding for large APIs with hundreds of endpoints.nav-item-spacing="default" (default): 7px vertical padding for balanced readability.nav-item-spacing="relaxed": 10px vertical padding for touchscreens and clean navigation.RapiDoc natively supports standard design system typography tokens. You can configure custom fonts by setting CSS variables on <rapi-doc>:
--font-sans or --font-regular: Primary font family for body text, headings, and navigation links.--font-mono: Monospace font family for code blocks, HTTP methods, route paths, and schema models.<head> <!-- 1. Load your preferred Google Fonts --> <link rel="preconnect" href="https://fonts.googleapis.com" /> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
<style> /* 2. Bind typography tokens directly to <rapi-doc> */ rapi-doc { --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; --font-mono: 'JetBrains Mono', 'Fira Code', monospace; } </style>
</head>
<body> <rapi-doc spec-url="https://petstore.swagger.io/v2/swagger.json" theme="emerald" color-scheme="dark" load-fonts="false" ></rapi-doc></body>/* Inherit from parent application font variables */rapi-doc { --font-sans: var(--font-inter, sans-serif); --font-mono: var(--font-jetbrains, monospace);}Because <rapi-doc> is a standard DOM element, you can dynamically switch themes, toggle light/dark modes, or adjust scale at runtime using standard JavaScript:
const doc = document.querySelector('rapi-doc');
// Switch brand preset or custom hex colorfunction setBrandColor(themeValue) { doc.setAttribute('theme', themeValue); // e.g., 'violet' or '#2563eb'}
// Toggle between dark and light modesfunction toggleDarkMode() { const current = doc.getAttribute('color-scheme') || 'dark'; doc.setAttribute('color-scheme', current === 'dark' ? 'light' : 'dark');}
// Adjust corner radius dynamicallyfunction updateRadius(radiusValue) { doc.setAttribute('radius', radiusValue); // 'none', 'sm', 'md', 'lg', 'full'}CSS Parts (::part)
Pierce the Shadow DOM to customize sidebars, action buttons, and containers with gradients and backdrop filters. Explore CSS Parts Guide
Pre-built Themes & Recipes
Copy-paste production presets for Fintech, Cloud, Web3, and Developer Portals. View Theme Recipes