Tabs
Switches between views of the same thing on one page.
In Content first
See it live
npm run storybookWhen to use it
In Content first: Views of the reading list, such as saved and finished. Not to move between site sections.
- Use it when: Related views of one object that people move between.
- Not when: Navigation to other pages (links), or steps of a task (progress).
Instead:
- Accordion: Stacked sections people can open together.
- Navigation menu: Other pages.
Words
- Write to one person: "you", not "users".
- Short sentences with room to breathe.
- Explain why before asking for anything.
- Use: Read, Save for later, You, Next issue. Avoid: Click here, Submit, Users, Content.
The labels components use, from the voice tokens:
content.action.commit: Savecontent.action.cancel: Not nowcontent.action.destroy: Removecontent.action.retry: Try againcontent.action.empty-action: Browse guides
See Voice and tone for the whole voice.
Accessibility and keyboard
| Keyboard | What happens | Not |
|---|---|---|
| undefined | Arrow keys move between tabs; Tab moves into the panel. | undefined |
Test before you ship:
- It is a tablist; the selected tab owns its panel. undefined
Use it in code
npx open-ds add tabs
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Tabs reads 14 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Tabs's tokens to change Tabs alone.
Content first decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Shared | ||
| Button focus ring Changes with theme on focus | component.button.focus-ringcolor.border.focusvar(--button-focus-ring) | Lightnavy.light.600:#1E3A5FDarknavy.dark.600:#8FA6C4 |
| Tabs | ||
| Indicator Changes with theme | component.tabs.indicatorcolor.action.primaryvar(--tabs-indicator) | Lightnavy.light.600:#1E3A5FDarknavy.dark.600:#8FA6C4 |
| Focus on focus | component.tabs.focusborder-width.focusvar(--tabs-focus) | border-width.2:2px |
| Canvas Changes with theme on focus | component.tabs.canvascolor.surface.canvasvar(--tabs-canvas) | Lightstone.light.50:#FFFDF8Darkstone.dark.0:#14110D |
| Text | ||
| Color Changes with theme | component.tabs.labelcolor.text.secondaryvar(--tabs-label) | Lightstone.light.700:#4A4339Darkstone.dark.500:#CFC6B6 |
| Active Changes with theme | component.tabs.label.activecolor.text.primaryvar(--tabs-label-active) | Lightstone.light.900:#1F1B16Darkstone.dark.900:#FFFDF8 |
| List | ||
| Gap | component.tabs.list.gapspace.gap.groupvar(--tabs-list-gap) | space.32:2rem |
| Border width | component.tabs.list.border-widthborder-width.defaultvar(--tabs-list-border-width) | border-width.1:1px |
| Border Changes with theme | component.tabs.list.bordercolor.border.defaultvar(--tabs-list-border) | Lightstone.light.200:#E4DDD0Darkstone.dark.100:#2E2A24 |
| Trigger | ||
| Height | component.tabs.trigger.heightsize.control.defaultvar(--tabs-trigger-height) | size.48:3rem |
| Font family | component.tabs.trigger.font-familytype.label.font-familyvar(--tabs-trigger-font-family) | font.family.inter:Inter, system-ui, sans-serif |
| Text size | component.tabs.trigger.font-sizetype.label.font-sizevar(--tabs-trigger-font-size) | font.size.16:1rem |
| Weight | component.tabs.trigger.font-weighttype.label.font-weightvar(--tabs-trigger-font-weight) | font.weight.600:600 |
| Content | ||
| Padding, top | component.tabs.content.padding-topspace.gap.defaultvar(--tabs-content-padding-top) | space.16:1rem |