Tabs and accordions
Use tabs to organize alternative content (like platform-specific instructions) and accordions for expandable sections (like FAQs).
Tabs
Style tabs with ::part(): tab-bar, tab and panel. Accordions and expandables have summary and content. See Custom CSS.
Tabs let readers switch between related content panels without leaving the page:
Install with Homebrew:
Install with your package manager:
Download the installer from nodejs.org.
dark or light.Arrow keys, Home and End move between tabs, and a # fragment in the URL that matches a tab's slug opens that tab. For example, #windows opens the Windows tab above. Tabs with icons and a default tab:
Install with npm.
Run the image. This tab is open first.
Synced tabs
Give several tab groups the same sync key and they switch together. A reader who picks "pnpm" in one place sees "pnpm" everywhere on the site. Tabs match by label, so the label text must be identical, and a group without a matching label stays as it is.
sync works on wc-tabs and on wc-code-group, and a wc-tabs can sync with a wc-code-group that uses the same key and labels. The choice is saved in the reader's browser. Try it here: switch either group and the other follows.
Use Homebrew on macOS.
Use your distribution's package manager.
When to use tabs
- Platform-specific instructions (macOS, Linux, Windows)
- Package manager alternatives (npm, pnpm, yarn)
- Language variants (JavaScript, Python, Go)
- Framework-specific examples (React, Vue, Angular)
Accordions
Accordions hide content behind a clickable title. Readers expand only the sections they need:
Run npm install -g docslit or use npx to run it without installing.
DocsLit requires Node.js 22.22.0 or later.
#id opens the item. Without it, the slug of the title is used.An accordion is a real button with aria-expanded, so it works from the keyboard and with screen readers, and the in-page search can find text inside a closed item. Here is one with a description, an icon and a deep link:
DocsLit requires Node.js 22.22.0 or later.
Accordion groups
Wrap accordions in wc-accordion-group for a visually connected set with continuous borders:
Yes. Place .js files in the components/ directory and they load automatically.
Yes. Configure versions in docslit.json to maintain docs for multiple releases.
Yes. The docslit build output is a standard static site that works anywhere.
Expandable sections
Use wc-expandable for a simpler collapsible section:
These options are for advanced users who need fine-grained control over the build output.
--offline— Build a self-contained offline site--out <dir>— Custom output directory
wc-expandable behaves like wc-accordion. It is meant for nested content, such as the properties of an object in an API field list.
Views
wc-view is a switcher for alternative views of the same content, such as a language or a platform. Its panels are wc-view-panel elements with a label and an optional icon. Give several view groups the same sync key, and they switch together.
Call the HTTP API directly.
Use the client library.
Use tabs for content that readers pick once, and views when the choice is a preference that applies across the page.