Tabs
One panel per alternative, with keyboard navigation and a shared choice across the document.
- #authoring
- #components
- #accessibility
Tabs are for genuine alternatives, meaning the same instruction written for a different tool, runtime or language. The reader needs exactly one of the panels, so stacking all of them as code blocks makes them read three snippets to find theirs.
They are the wrong shape for sequential content. A panel a reader has to open to know they need it is hidden content, not organised content.
A shared choice
A group key ties every tab set in the document to the same selection. A reader
who picks pnpm at the top of a long guide sees pnpm in every block after it,
instead of picking it again at each one. The block above and the one below share
the package-manager group. Change one and the other follows.
Rich panels
A panel holds whatever a document holds, including prose, lists and nested components, not only code:
Entries live on the filesystem under content/. The pipeline discovers them,
derives metadata from the path and document, and checks every internal link
while the site builds.
- Bun 1.2 or newer
- A browser with ES2022 support
- A clean working tree before
bun run check
Keyboard and semantics
The tab strip is a real tablist. ← and → move between
tabs, Home and End jump to the ends, and the selected tab
is the only one in the tab order, so a reader is not made to tab through four
labels to reach the panel.
Props
<Tabs />
items?string[]
Tab labels, in order. Each one matches a Tab by its value.
defaultValue?string
Which tab opens selected.
- Default
the first item
group?string
Shared key. Every Tabs block with this key follows the same choice.
<Tab />
valuestring
Matches one of the parent's items.
label?string
Overrides the label taken from items.