Skip to content

Navigation

Tabs

Switches between panels on the same page without changing the URL, e.g. Preview and Code.

  • Experimental
  • Keyboard tested
  • Screen reader not tested yet

Updated 2026-11-12

Playground

Change the props and the surface. The controls come from the documented props; the surfaces are the real modes.

Preview panel.

tsx
<Tabs
  label="Playground tabs"
  items={[
    {
      id: "preview",
      label: "Preview",
      content: <p className="text-secondary">Preview panel.</p>,
    },
    {
      id: "code",
      label: "Code",
      content: <p className="text-secondary">Code panel.</p>,
    },
  ]}
/>

Usage

When to use

Use tabs to switch between panels of the same content on one page, without changing the URL: Preview and Code, for example.

When not to use

  • For subpages with their own URL: use TabNav.
  • When people need to see both panels at once: show them one after the other.

How it works

An ARIA tablist: only the selected tab is in the Tab order, the arrow keys move between tabs, and the panel follows. The selected tab is marked with an underline.

Content guidelines

Two to five short labels, one or two words each.

Do and don’t

Do
  • Two to five short tab labels.
Don’t
  • Don't use Tabs for subpages with their own URL; use TabNav.

Anatomy

The parts of the component and what each one does, as in the playground above.
  1. tab14px medium; selected tab in text.primary with a 2px accent line.
  2. indicator2px accent line under the selected tab.
  3. panelContent of the selected tab.

Examples

Type-checked, and the same code goes into the AI manifest. Import: import { Tabs } from "@/ds";

Two panels

Preview panel.

Props

Checked against the component's TypeScript type on every build.
Tabs props
NameTypeDefaultDescription
label (required)string–Accessible name of the tab list.
items (required)TabItem[]–id, label and content per tab.
defaultSelectedstring–id of the tab selected first.

Tokens used

Derived from the utility classes in the component's source. Copy a class with one click.
Tokens used by Tabs
TokenTierValueUtility
button.radiuscomponent9999px
tabs.bordercomponentrgba(10,10,11,0.08)
tabs.fgcomponent#555555
tabs.fgHovercomponent#0A0A0B
tabs.fgSelectedcomponent#0A0A0B
tabs.indicatorcomponent#C6492E
focussemantic#C6492E
spacing.0semantic0px
spacing.3semantic12px
spacing.6semantic24px
surface.pagesemantic#FAFAF7
text.secondarysemantic#555555
type.small.sizesemantic14px
weight.mediumsemantic500

Accessibility

What is checked automatically on every build, and what a person has tested. Nothing is marked as tested unless it was.
Testing status by check
CheckHowStatus
axe-core rulesAutomated on every npm run check, at desktop and mobile widthRuns on every build
KeyboardAutomated Playwright test (scripts/keyboard.mjs)Tested
Screen readerManualNot tested yet

Keyboard

Tabs keyboard interactions
KeyAction
TabMoves into the tab list, then into the panel.
Arrow left / rightSelects the previous or next tab.
Home / EndSelects the first or last tab.

Semantics and focus

  • role="tablist", "tab" and "tabpanel" with aria-selected and aria-controls, from React Aria.
  • Only the selected tab is in the Tab order; arrow keys move between tabs.

Contrast

Tabs contrast pairings
PairingRatio (x:1)MinimumStatus
text.primary on surface.page18.924.5Pass
text.secondary on surface.page7.134.5Pass
accent.default on surface.page4.574.5Pass
focus on surface.page4.573.0Pass