Tabs
Switches between views of the same thing on one page.
In Brand expressive
See it live
npm run storybookWhen to use it
In Brand expressive: A few related views of one drop, such as line-up and countdown. Not for links to other pages.
- 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
- Headlines are short and bold. Three to six words.
- Verbs that move: Join, Try, Go.
- Playful in headlines, plain in errors.
- Use: Join, Drop, Go, Love. Avoid: Synergy, Leverage, Kindly.
The labels components use, from the voice tokens:
content.action.commit: Gocontent.action.cancel: Not nowcontent.action.destroy: Removecontent.action.retry: Try againcontent.action.empty-action: Explore the drop
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.
Brand expressive 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) | Lightpink.light.600:#D61F7ADarkpink.dark.600:#F59ACA |
| Tabs | ||
| Indicator Changes with theme | component.tabs.indicatorcolor.action.primaryvar(--tabs-indicator) | Lightpink.light.600:#D61F7ADarkpink.dark.600:#F59ACA |
| Focus on focus | component.tabs.focusborder-width.focusvar(--tabs-focus) | border-width.3:3px |
| Canvas Changes with theme on focus | component.tabs.canvascolor.surface.canvasvar(--tabs-canvas) | Lighttaupe.light.50:#FFF8F3Darktaupe.dark.0:#120B09 |
| Text | ||
| Color Changes with theme | component.tabs.labelcolor.text.secondaryvar(--tabs-label) | Lighttaupe.light.700:#4D3A33Darktaupe.dark.500:#E2C4B3 |
| Active Changes with theme | component.tabs.label.activecolor.text.primaryvar(--tabs-label-active) | Lighttaupe.light.900:#1F1411Darktaupe.dark.900:#FFF8F3 |
| List | ||
| Gap | component.tabs.list.gapspace.gap.groupvar(--tabs-list-gap) | space.40:2.5rem |
| Border width | component.tabs.list.border-widthborder-width.defaultvar(--tabs-list-border-width) | border-width.2:2px |
| Border Changes with theme | component.tabs.list.bordercolor.border.defaultvar(--tabs-list-border) | Lighttaupe.light.200:#F2DCCFDarktaupe.dark.100:#33241F |
| Trigger | ||
| Height | component.tabs.trigger.heightsize.control.defaultvar(--tabs-trigger-height) | size.52:3.25rem |
| Font family | component.tabs.trigger.font-familytype.label.font-familyvar(--tabs-trigger-font-family) | font.family.dm-sans:"DM Sans", system-ui, sans-serif |
| Text size | component.tabs.trigger.font-sizetype.label.font-sizevar(--tabs-trigger-font-size) | font.size.15:0.9375rem |
| Weight | component.tabs.trigger.font-weighttype.label.font-weightvar(--tabs-trigger-font-weight) | font.weight.700:700 |
| Content | ||
| Padding, top | component.tabs.content.padding-topspace.gap.defaultvar(--tabs-content-padding-top) | space.16:1rem |