Styling with CSS
The theming attributes cover colors, radius and scale. For anything else, RapiDoc offers two hooks into its Shadow DOM, where ordinary CSS selectors can’t reach:
- CSS custom properties, set on
rapi-doc, change colors, fonts and sizes everywhere they are used. - CSS parts, selected with
rapi-doc::part(name), style one kind of element directly.
1. Using ::part()
Section titled “1. Using ::part()”In your page’s CSS, write rapi-doc::part(name):
/* Target the navigation sidebar panel inside RapiDoc */rapi-doc::part(section-navbar) { background: linear-gradient(180deg, #090d16 0%, #030712 100%); border-right: 1px solid rgba(56, 189, 248, 0.15); box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);}
/* Target the header wrapper inside the navigation bar */rapi-doc::part(section-navbar-header) { border-bottom: 1px solid rgba(255, 255, 255, 0.08); padding: 16px;}Pseudo-classes
Parts work with pseudo-classes such as :hover, :focus and :active: rapi-doc::part(btn-fill):hover.
2. All CSS parts
Section titled “2. All CSS parts”Every part, with what it selects, is in the reference.
3. CSS custom properties
Section titled “3. CSS custom properties”Set variables on rapi-doc in your stylesheet or inline style:
rapi-doc { /* Override surface tokens */ --background: #0b1121; --foreground: #f8fafc; --card: #0f172a; --border: #1e293b;
/* Override typography tokens */ --font-sans: 'Inter', sans-serif; --font-mono: 'JetBrains Mono', monospace;
/* Override radius token */ --radius: 8px;}Every variable, with its default, is in the reference.
Headings
Section titled “Headings”RapiDoc’s titles are real headings, in one outline: the API title is h1; servers, authentication, tag groups and tags are h2; operation summaries h3; Request, Response, Code samples and Callbacks h4; parameter, request-body and response-header labels h5; a callback’s request and response h6. Headings in your Markdown descriptions use the same scale, so both line up.
Change the scale with custom properties, or style one level with the heading-1 … heading-6 parts (every heading also has the heading part):
rapi-doc { --heading-weight: 600; --heading-line-height: 1.2; --line-height: 1.75; --h1-font-size: 2.25rem; --h2-font-size: 1.75rem; --h3-font-size: 1.375rem;}
rapi-doc::part(heading-2) { border-bottom: 1px solid #334155; padding-bottom: 0.25em;}4. Recipes
Section titled “4. Recipes”Frosted-glass sidebar
Section titled “Frosted-glass sidebar”/* Frosted glass backdrop blur on sidebar */rapi-doc::part(section-navbar) { background: rgba(10, 15, 26, 0.85); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-right: 1px solid rgba(255, 255, 255, 0.08);}
/* Sidebar header area (wrapping logo & search) */rapi-doc::part(section-navbar-header) { padding: 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.06);}
/* Real-time search filter input inside sidebar */rapi-doc::part(textbox-nav-filter) { background: rgba(15, 23, 42, 0.6); border: 1px solid rgba(56, 189, 248, 0.2); border-radius: var(--radius); color: #f8fafc; padding: 8px 12px;}
rapi-doc::part(textbox-nav-filter):focus { border-color: #06b6d4; box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);}Gradient buttons
Section titled “Gradient buttons”/* Base button enhancements */rapi-doc::part(btn) { border-radius: var(--radius); font-weight: 600; transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);}
/* Primary filled buttons, such as TRY */rapi-doc::part(btn-fill) { background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%); color: #ffffff; border: none; padding: 8px 16px; box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25);}
rapi-doc::part(btn-fill):hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(6, 182, 212, 0.4);}Server panel
Section titled “Server panel”/* Server selector container */rapi-doc::part(section-servers) { background: rgba(15, 23, 42, 0.7); border: 1px solid rgba(56, 189, 248, 0.2); border-radius: var(--radius); padding: 16px 20px;}
/* Selected base URL indicator */rapi-doc::part(label-selected-server) { color: #38bdf8; font-family: var(--font-mono); font-weight: 600;}Which to use
Set the basics with attributes (theme, color-scheme, radius, scale) and variables, and keep ::part() for what they can’t do, such as gradients, backdrop filters and borders on specific containers.
5. Schema descriptions
Section titled “5. Schema descriptions”In both Tree mode and Table mode, each schema row shows its description on a single line. Click a description (or its ➔ arrow) to expand that row, and click again to collapse it. The Multiline description toolbar button expands every row at once.
Layout Differences
Section titled “Layout Differences”In Tree mode, property names, data types, constraints, and descriptions are displayed in a continuous, hierarchically indented horizontal line:
- Field Column: Has a dynamic minimum column width (
min-width: calc(400px - indent)). - Long Property Names: Truncated with an ellipsis, with the full name in a hover tooltip (
title="..."). Expanding the row also shows the full name.
In Table mode, the schema is formatted into a strict 3-column CSS subgrid:
- Field Column (
.key): Dedicated column with a width controlled by--table-schema-key-width(default:240px). Long property names truncate with an ellipsis and show full text via hover tooltips (title="..."). - Type Column (
.key-type): Fixed minimum column (~150px) displaying data types and nullability badges. - Description Column (
.key-descr): Flexible1frcolumn spanning the remaining container width.
What a collapsed row shows
Section titled “What a collapsed row shows”| Description content | Collapsed row | ➔ arrow |
|---|---|---|
| One paragraph that fits | The whole paragraph | No |
| One paragraph that is too long for the column | The start of the paragraph, cut off with an ellipsis | Chrome and Edge (see below) |
Several paragraphs, a list with several items, or a <br> line break |
The first paragraph or list item | Yes |
| A table, code block, HTML block or blockquote first | A one-line summary: Table · 3 rows, Code block · json, the text of the HTML, or the quote’s first line |
Yes |
| A heading first | The heading text, at description size | Yes, when more follows |
A schema title before a list, heading, table or code block |
Title: and the first line of that block |
Yes |
| A description plus constraints, default, allowed values or pattern | The description; the constraint chips are hidden | Yes |
| Constraints only, no description | The constraint chips | No |
| Nothing | An empty cell | No |
Whether a line is too long is decided by the browser at the actual column width and font, not by counting characters, so it adapts to split panes, sidebars and resizing without any JavaScript.
Long lines
Section titled “Long lines”A cut-off line always ends with a plain ellipsis in the text color. The ➔ arrow is the only control.
- Chrome and Edge (133+): a row whose line is cut off also shows the
➔arrow and a pointer cursor. This uses a CSS scroll-state container query. - Other browsers: the ellipsis is the only cue. Clicking the text still expands the row.
An expanded row keeps its arrow, pointing up, so it can be collapsed again. A row with nothing more to show (a line that fits, and no arrow) doesn’t react to clicks.
rapi-doc { /* Allocate more width for property names in Table mode */ --table-schema-key-width: 300px;}6. Parameter Lists
Section titled “6. Parameter Lists”Request parameters, request-body form fields, response headers, and server variables share one layout: a <ul part="param-list"> grid with one <li part="param"> per parameter. Each parameter is a subgrid row with up to four pieces:
| Part | Column | Content |
|---|---|---|
param-label |
1 | param-name (required marker, deprecated icon) and param-type |
param-input |
2 | Try-it input; spans columns 2–3 when there are no constraints |
param-constraint |
3 | Default, pattern, range, allowed values; spans columns 2–3 when there is no input |
param-details |
2–3 | Description and examples, on the next row |
Allowed values and short-format examples are a value-list: a value-list-label followed by value-list-items. Wrapped values line up under the first value, and the ┃ separators are drawn in CSS so they stay at the end of a line. Space them with --value-list-gap, --value-list-row-gap, and --value-list-label-gap.
Below about 36rem of available width the list stacks into a single column. Size it with --param-label-width, --param-gap, --param-row-gap, and --param-padding:
rapi-doc { --param-label-width: 14rem; --param-padding: 0.75rem;}rapi-doc::part(param-name) { font-weight: 600;}rapi-doc::part(param-details) { color: var(--muted-foreground);}
