Demos

Default pill tabs.

Usage

Use tabs to switch between views of the same subject, such as the overview, history, and notes of one biomarker. Do not use tabs for steps in a sequence, or for content the reader needs to compare at once.

Import it from @workspace/ui/components/tabs.

Anatomy

  • Tabs — Holds the active value and the orientation.
  • TabsList — The row of triggers. variant sets the style.
  • TabsTrigger — One tab. Its value matches a panel.
  • TabsContent — The panel shown when its tab is active.

Notes

  • Arrow keys move between tabs. Tab moves into the active panel.
  • Keep labels to one or two words.
  • Line tabs are quieter. Use them when tabs sit inside a busy page.
  • tabsListVariants is exported to style other elements like a tab list.

Examples

Line

Set variant="line" on TabsList for a quieter style.

Vertical

Set orientation="vertical" to stack the tabs beside the content.

Disabled

Disable a tab that has nothing to show yet.

Controlled

Hold the active tab with value and onValueChange.

Props

These are the props you set most often. Unlisted props pass through to the underlying element.

Tabs

PropTypeDefaultDescription
defaultValueany0Active tab on first render.
valueany—Active tab when controlled.
onValueChange(value) => void—Called when the active tab changes.
orientation"horizontal" or "vertical"horizontalDirection of the list.

TabsList

PropTypeDefaultDescription
variant"default" or "line"defaultFilled pill track or an outlined track.

TabsTrigger

PropTypeDefaultDescription
valueany—Identifies the tab and its panel.
disabledbooleanfalseStops the tab from being selected.