Themes, Brand Colors & Typography
RapiDoc features a streamlined, token-driven styling architecture inspired by modern design systems. Configure rich color presets, custom brand hex colors, contrast modes, typography, and corner radius using clean declarative attributes.
The Four Primary Styling Attributes
Instead of dozens of disparate color properties, RapiDoc consolidates visual styling into four high-leverage attributes:theme, color-scheme, radius, and scale.
Instant Declarative Theming
Configure complete visual styling directly in your HTML tag with zero CSS boilerplate or build steps required.
| Attribute | Type / Allowed | Default | Description & Behavior |
|---|---|---|---|
theme | preset | #hex ember, carbon, cobalt, jade, indigo, or #hex | ember | Sets the brand color palette. Accepts one of the five built-in presets or a custom brand color hex code (e.g. #2563eb). |
color-scheme | string dark | light | system | dark | Controls dark or light surface mode. When set to "system", RapiDoc automatically switches based on the user OS prefers-color-scheme setting. |
radius | string none | sm | md | lg | full | sm | Corner radius scale applied to cards, buttons, badges, parameter inputs, and dialogs (--radius). |
scale | string sm | default | lg | default | Proportionally scales UI base dimensions, body fonts, monospace code blocks, and sidebar width across the documentation. |
nav-item-spacing | string compact | default | relaxed | default | Controls vertical density and padding of sidebar navigation links independently of typography scale. |
render-style | string focused | read | view | focused | Document presentation layout mode: single-operation focused console, continuous reading doc, or multi-column interactive view. |
schema-style | string tree | table | tree | Visual formatting of request and response payload schemas (interactive collapsible tree or structured property table). |
Built-in Presets & Custom Hex Brand Colors
Choose from curated presets matched to modern design systems, or pass any corporate brand hex color directly into theme.
Orange-red accent over neutral charcoal. Warm and high-energy; the RapiDoc house theme.
Monochrome: near-black surfaces with a white accent, like a terminal or IDE. Black on white in light mode.
Matte steel-blue accent over grey-blue slate, cards a shade darker than the page. Understated, for cloud and enterprise APIs.
Green accent over slate-navy, cards a shade darker than the page. Suits payments, banking and infrastructure APIs.
Indigo accent over indigo-black surfaces, for SaaS and platform products.
Hex Color Dynamic Contrast Engine
Pass your corporate brand color (such as #2563eb or #ff5722) directly to theme. RapiDoc automatically calculates perceived YIQ luminance, assigns the focus ring and primary token, and guarantees accessible contrast on button text by dynamically selecting pure black or crisp white.
<!-- Use your corporate brand hex color directly -->
<rapi-doc
spec-url="https://api.acme.corp/openapi.json"
theme="#2563eb"
color-scheme="dark"
radius="lg"
scale="default"
></rapi-doc>
<!--
RapiDoc automatically analyzes #2563eb luminance:
- Generates --primary: #2563eb
- Generates --ring: #2563eb
- Generates high-contrast --primary-foreground: #ffffff
-->Corner Radius & Sizing Scale
Calibrate corner roundness and base density to match your product's UI design language.
Corner Radius (radius)
Controls roundness across cards, buttons, badges, parameter inputs, and dialogs:
radius="none"0px sharp geometric cornersradius="sm"4px (0.25rem) — Default sleek modernradius="md"6px (0.375rem) balanced roundnessradius="lg"8px (0.5rem) pronounced roundnessradius="full"Pill buttons/inputs (9999px), 8px cards
UI Scale (scale)
Harmoniously scales base sizing, font dimensions, and sidebar width:
- Ideal for embedded widgets and compact consoles
scale="sm"Compact (13px base, 17rem nav) - Standard desktop layout for public developer hubs
scale="default"Standard (14px base, 18.75rem nav) - Enhanced readability, high-DPI displays, and presentations
scale="lg"Generous (16px base, 21rem nav)
Custom Typography & Brand Fonts
RapiDoc loads no web fonts and uses the operating system's UI font by default. Set --font-sans and --font-mono on <rapi-doc> to apply your brand fonts.
Pairing Inter & JetBrains Mono
Self-host the font files, declare them with @font-face in the page, and bind the tokens in CSS. A Google Fonts stylesheet or a Fontsource package works the same way; see Typography & Brand Fonts.
<style>
/* Declare fonts in the page: @font-face inside RapiDoc's shadow root is ignored */
@font-face {
font-family: 'Inter';
src: url('/fonts/InterVariable.woff2') format('woff2');
font-weight: 100 900;
font-display: swap;
}
@font-face {
font-family: 'JetBrains Mono';
src: url('/fonts/JetBrainsMono-Variable.woff2') format('woff2');
font-weight: 100 800;
font-display: swap;
}
/* Override typography tokens directly on <rapi-doc>, keeping system fonts as the fallback */
rapi-doc {
--font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
--font-mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}
</style>
<rapi-doc
spec-url="https://petstore.swagger.io/v2/swagger.json"
theme="violet"
color-scheme="dark"
radius="md"
></rapi-doc>Dynamic Runtime Theming via JavaScript
Because RapiDoc is a standard custom HTML element, its styling attributes reflect instantly when modified through vanilla DOM methods.
// Select the RapiDoc custom element in the DOM
const doc = document.querySelector('rapi-doc');
// Switch theme preset or brand color
function setBrandTheme(presetOrHex) {
doc.setAttribute('theme', presetOrHex); // e.g. 'cobalt', 'jade', or '#ff5722'
}
// Toggle between dark and light modes
function toggleColorScheme() {
const current = doc.getAttribute('color-scheme') || 'dark';
doc.setAttribute('color-scheme', current === 'dark' ? 'light' : 'dark');
}
// Adjust corner roundness dynamically
function setRadius(size) {
doc.setAttribute('radius', size); // 'none', 'sm', 'md', 'lg', 'full'
}
// Switch UI scaling dynamically
function setScale(size) {
doc.setAttribute('scale', size); // 'sm', 'default', 'lg'
}