Segmented control

Pick one of a few mutually-exclusive options shown as connected segments — the labeled, horizontal alternative to a stack of radios; it sets a value, it does not switch views (that is Tabs). Built as a radiogroup of visually-hidden native radios, so arrow keys move selection and exactly one segment stays checked with no JS.

Segmented control · Wired

Real wiring, no demo chrome: click or focus a segment and arrow between options — native radios do all of it. A disabled segment stays visible but is skipped.

Sizes

One sm/md/lg dialect — track height and label size follow size.interactive, while button-like segment inset scales through space.2 / space.3 / space.4. The selected fill sits half of space.1 inside the track.

ExampleSizeModifierHeightUsage
Small--smsize.interactive.smDense surfaces: toolbars, filter bars
Mediumds-segmentedsize.interactive.mdThe default — most surfaces
Large--lgsize.interactive.lgHigh-emphasis, touch targets

Segment states

State lives on the segment. Each row applies it to the first segment; real drivers set every state and the demo classes force hover and focus here.

ExampleStateDriverRolesUsage
Resttext.secondaryAn option not currently chosen
Hover:hovertext.primaryThe text lifts; the fill stays reserved for selection
Selected:has(:checked)selection.bgtext.primaryThe persistent chosen segment — exactly one per group
Focus:focus-visiblefocus.ringKeyboard focus on the segment
Disabled:disabledaction.disabled.textVisible but not pickable

Usage notes

A segmented control answers one question: which mode, from two to five that fit on a line.

VerdictRule
DoGive the group an accessible name via aria-label or aria-labelledby — the segments are the radios' labels.
DoSeed an initial selection — exactly one segment is checked at all times; never render an all-unselected group.
DoKeep role="radiogroup" with native radios so selection is announced as "radio, selected", not as buttons.
Don’tStretch it past 2–5 short options of similar length — more or longer belongs in a Select, and switching views is Tabs.
Don’tSignal selection with hue alone — the filled cell and native checked state carry the choice without depending on brand color.