Skip to content

Segmented Control

A compact row of options that switches one mode, view or filter.

Run history

  • Summarize support ticketSucceeded · 2 min ago
  • Translate release notesFailed · 9 min ago
  • Classify inbound emailSucceeded · 14 min ago
  • Generate weekly reportFailed · 1 hr ago
hero.tsx

Usage guidelines

  • Use SegmentedControl for one mode, view or filter for content that stays in place. Use Tabs when the choice swaps the panel it controls, and RadioGroup for one persistent field value from a small set of options that all stay visible.
  • Pass value or defaultValue. One item is always selected and the selected item cannot be cleared, so the control has no empty state.
  • Name the group with aria-label, or with aria-labelledby when visible text already labels it. Items take their name from their text; give an icon-only item an aria-label, mark its icon aria-hidden and pair it with a Tooltip that shows the same words.
  • Keep the caller's value type. SegmentedControl<Value> and SegmentedControlItem<Value> accept unions and numbers; type each item when its value is not a string.
  • Items render native type="button" elements, so they never submit a surrounding form. The control owns the track, the focus ring and the sliding selection thumb; keep its density and dimensions when adopting it.
  • Use RadioGroup with RadioItem instead when the options need a custom single-choice surface, such as separate filter pills.

Anatomy

tsx
tsx

Examples

Icons and icon-only items

Put a decorative icon before the label, or use the icon alone with an aria-label on the item and a Tooltip that shows the same words, with the item as the render of TooltipTrigger. Wrap adjacent tooltips in TooltipProvider so moving between items skips the open delay.

icons.tsx

Typed controlled value

Control the value with value and onValueChange when another part of the page reads it. Here the value is a number union, typed on the root and on each item.

Showing 25 logs per page.

typed-value.tsx

Dividers and disabled items

SegmentedControlDivider separates items and hides itself next to the selected one. A disabled item stays visible and is skipped by the keyboard.

12-month retention requires the Team plan.

divider-disabled.tsx

Keyboard

KeyAction
TabMoves focus into the control on the selected item, then out of it.
Right arroworDown arrowMoves focus to the next enabled item and selects it, wrapping at the end.
Left arroworUp arrowMoves focus to the previous enabled item and selects it, wrapping at the start.

API reference

SegmentedControl

A single-choice segmented control with an animated selection thumb for mode, filter, or view switching. Renders a <div> element.

Requires either value or defaultValue. Use Tabs instead when each option controls a corresponding panel.

Base UI RadioGroup docs

Props
PropTypeDefaultDetails
defaultValueValueNo default
valueValueNo default
Base UI RadioGroup docs

Valid prop combinations:

  • defaultValue: Value, value?: undefined
  • value: Value, defaultValue?: undefined
Data attributes
AttributeDescription
data-disabled

Present when the radio group is disabled.

SegmentedControlDivider

Accepts the props of the element it renders.

SegmentedControlItem

An individual option inside SegmentedControl. Renders a <button> element and a hidden <input> beside.

Base UI Radio.Root docs

Props
PropTypeDefaultDetails
nativeButtonbooleantrue
Base UI Radio.Root docs
Data attributes
AttributeDescription
data-checked

Present when the radio is checked.

data-unchecked

Present when the radio is not checked.

data-disabled

Present when the radio is disabled.

data-readonly

Present when the radio is readonly.

data-required

Present when the radio is required.

data-valid

Present when the radio is in a valid state (when wrapped in Field.Root).

data-invalid

Present when the radio is in an invalid state (when wrapped in Field.Root).

data-touched

Present when the radio has been touched (when wrapped in Field.Root).

data-dirty

Present when the radio's value has changed (when wrapped in Field.Root).

data-filled

Present when the radio is checked (when wrapped in Field.Root).

data-focused

Present when the radio is focused (when wrapped in Field.Root).