SegmentedControl

Fiddle
2–5 exclusive views. Tabs for page sections, SegmentedControl for a view toggle.

Usage

The import, then a use to start from. Both copy as they are.

Import
import {    SegmentedControl,    SegmentedControlContent,    SegmentedControlList,    SegmentedControlTrigger} from "@/components/ui/segmented-control";
Example
<SegmentedControl value={view} onValueChange={setView}>    <SegmentedControlList aria-label="View">        <SegmentedControlTrigger value="chart">Chart</SegmentedControlTrigger>        <SegmentedControlTrigger value="table">Table</SegmentedControlTrigger>    </SegmentedControlList>    <SegmentedControlContent value="chart">{chart}</SegmentedControlContent>    <SegmentedControlContent value="table">{table}</SegmentedControlContent></SegmentedControl>

When to use

Use it for

  • 2 to 5 exclusive views of the same thing: chart or table, light or dark, a time range.
  • Labels of one or two words, or icons with an aria-label each.
  • SegmentedControlContent when each segment shows its own panel; leave it out for a plain value toggle.

Avoid

  • Sections of a page that people move between: those are Tabs.
  • More than 5 options, or options that need a sentence: use a Select or a RadioGroup.

Accessibility

Checks

  • The arrow keys move between segments, and the list's aria-label names what it switches.

API

Read from each component's stories, the same source as COMPONENTS.md, and kept in step by check:design-system.

SegmentedControl

Its stories don't declare argTypes, so no props are listed. The variants show its states.
Also exportsSegmentedControlContentSegmentedControlListSegmentedControlTrigger
VariantsDefaultWithContentIconsOnlyOnSidebarSurfaceThreeSegments

Keep going