Custom CSS

|
|

Set css in docslit.json to the path of your stylesheet. DocsLit copies it into the build output and links it after the theme stylesheet, so your rules win at equal specificity. For colors, fonts and spacing, prefer design tokens. Use custom CSS for everything else.

{ "css": "styles/custom.css" }

Layout attributes

Each page region carries a data-layout-item attribute. Target the attribute instead of a class when you want a selector that survives theme changes.

Attribute value Region
topbar The top navigation bar
sidebar The left sidebar
content The page content
toc The on-page table of contents
footer The site footer
pagination The previous and next page links
banner The announcement banner
search-entry The search button in the top bar

The theme toggle has data-component-name="theme-toggle". The <html> element has data-current-path="/<page id>", for example data-current-path="/customization/custom-css". DocsLit updates it after each client-side navigation, so you can style one page or one section:

html[data-current-path^="/api/"] [data-layout-item="toc"] { display: none; }

Mintlify-style hooks

Stylesheets written for Mintlify target ids such as #sidebar and classes such as .card. DocsLit doesn't emit those ids, because they would collide with heading anchors. Instead, the build rewrites them in the file you set with css. The rewrite changes only selectors, and it keeps each selector's specificity. Declarations, comments, strings and at-rule preludes are copied as they are.

The dev server serves the stylesheet translated the same way. To serve and build the file unchanged, set cssHooks to false:

{ "css": "styles/custom.css", "cssHooks": false }

Region hooks

Hook DocsLit element
#navbar The top bar
#header The top row of the docs area
#sidebar The sidebar
#sidebar-content The scrolling part of the sidebar
#content-area The main column
#content The page content
#page-title The page's h1
#footer The site footer
#pagination The previous and next links
#banner The announcement banner
#table-of-contents The on-page table of contents
#table-of-contents-content The scrolling part of the table of contents
#search-bar-entry The search button
#topbar-cta-button The primary button in the top bar
#page-context-menu The contextual menu
Hook DocsLit element
.toc The table of contents
.sidebar-group-header A sidebar group title
.sidebar-title A sidebar item label

.toc-item is already a DocsLit class, so it needs no rewrite.

Component hooks

Component hooks match the component's host element. To style what's inside, use parts.

Hook DocsLit element
.card wc-card
.callout wc-callout and wc-alert
.code-block wc-code-block
.code-group wc-code-group
.frame wc-frame
.tabs wc-tabs
.steps wc-steps
.step wc-step
.accordion wc-accordion
.accordion-group wc-accordion-group
.expandable wc-expandable
.tooltip wc-tooltip
.update wc-update
.tile wc-tile
.badge wc-badge
.field wc-field

Component parts

DocsLit components use Shadow DOM, so a normal selector can't reach their insides. Each component exposes named parts that you style with ::part():

wc-card::part(title) { letter-spacing: -0.01em; }
Component Parts
wc-card image, icon, title, content, cta
wc-callout, wc-alert root, icon, content
wc-code-block root, header, copy-button
wc-code-group root, tab-bar, tab-content, copy-button
wc-tabs tab-bar, tab, panel
wc-accordion, wc-expandable summary, content
wc-step number, title, content
wc-prompt body, description, actions, copy-button

Run docslit components <tag> --json to list the parts of any component.

Mintlify's [data-component-part] selectors are rewritten to these parts:

Hook Becomes
card-icon, card-title, card-content, card-image, card-cta wc-card::part(icon), title, content, image, cta
code-block-root wc-code-block::part(root)
code-group-tab-bar, code-group-tab-content wc-code-group::part(tab-bar), tab-content
prompt wc-prompt::part(body)
prompt-description wc-prompt::part(description)
prompt-actions-wrapper wc-prompt::part(actions)
prompt-action-copy-button wc-prompt::part(copy-button)

A part hook is rewritten only when it ends a selector. It can be followed by :hover, :focus, :focus-visible, :focus-within or :active. A preceding component class merges into the host, so .card [data-component-part="card-title"] becomes wc-card::part(title). In any other position the selector stays as you wrote it and the build prints a warning.

Example stylesheet

/* styles/custom.css */ #sidebar { border-right: 1px solid var(--border); } .sidebar-group-header { text-transform: uppercase; letter-spacing: 0.06em; } .card [data-component-part="card-title"] { font-weight: 700; } [data-layout-item="footer"] { margin-top: 4rem; } html[data-current-path="/getting-started/introduction"] [data-layout-item="toc"] { display: none; }

This stylesheet does five things:

  • Adds a divider to the sidebar.
  • Uppercases sidebar group titles.
  • Bolds card titles, through wc-card::part(title).
  • Adds space above the footer.
  • Hides the table of contents on the introduction page.