Navigation
TabNav
Links to subpages that look like tabs. Navigation, not an ARIA tablist: every item has its own URL.
- Experimental
- Keyboard tested
- Screen reader not tested yet
Playground
Change the props. The controls come from the documented props.
<TabNav
label="Playground subpages"
current="#overview"
items={[
{ label: "Overview", href: "#overview" },
{ label: "Usage", href: "#usage" },
{ label: "Code", href: "#code" },
]}
/>Usage
When to use
Use TabNav for two to five subpages of one topic that each have their own URL, such as a component's Overview, Usage, Code and Accessibility pages.
When not to use
- To switch panels on the same page without a URL: use Tabs.
- For the main navigation: use Nav.
How it works
Links styled as tabs, with the current page marked by aria-current and an underline. It is navigation, not an ARIA tablist: screen readers announce links, which is what they are.
Content guidelines
Labels are one word where possible and match the page titles.
Do and don’t
Do
- For two to five subpages of one topic, such as a component's tabs.
Don’t
- Don't use it to switch panels without a URL; use Tabs.
Anatomy
The parts of the component and what each one does, as in the playground above.
- link14px medium; the current page in text.primary.
- indicator2px accent line under the current page.
Examples
Type-checked, and the same code goes into the AI manifest. Import: import { TabNav } from "@/ds";
Component subpages
Props
Checked against the component's TypeScript type on every build.
| Name | Type | Default | Description |
|---|---|---|---|
| label (required) | string | – | Accessible name of the landmark, unique per page. |
| items (required) | TabNavItem[] | – | label and href per subpage. |
| current (required) | string | – | Path of the current page. |
Tokens used
Derived from the utility classes in the component's source. Copy a class with one click.
| Token | Tier | Value | Utility |
|---|---|---|---|
| button.radius | component | 9999px | |
| tabs.border | component | rgba(10,10,11,0.08) | |
| tabs.fg | component | #555555 | |
| tabs.fgHover | component | #0A0A0B | |
| tabs.fgSelected | component | #0A0A0B | |
| tabs.indicator | component | #C6492E | |
| focus | semantic | #C6492E | |
| spacing.0 | semantic | 0px | |
| spacing.3 | semantic | 12px | |
| spacing.6 | semantic | 24px | |
| surface.page | semantic | #FAFAF7 | |
| type.small.size | semantic | 14px | |
| weight.medium | semantic | 500 |
Accessibility
What is checked automatically on every build, and what a person has tested. Nothing is marked as tested unless it was.
| Check | How | Status |
|---|---|---|
| axe-core rules | Automated on every npm run check, at desktop and mobile width | Runs on every build |
| Keyboard | Automated Playwright test (scripts/keyboard.mjs) | Tested |
| Screen reader | Manual | Not tested yet |
Keyboard
| Key | Action |
|---|---|
| Tab | Moves from link to link. |
| Enter | Opens the subpage. |
Semantics and focus
- A <nav> with links; the current page has aria-current="page".
- No tablist role: screen readers announce links, which is what they are.
Contrast
| Pairing | Ratio (x:1) | Minimum | Status |
|---|---|---|---|
| text.primary on surface.page | 18.92 | 4.5 | Pass |
| text.secondary on surface.page | 7.13 | 4.5 | Pass |
| accent.default on surface.page | 4.57 | 4.5 | Pass |
| focus on surface.page | 4.57 | 3.0 | Pass |