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
Usage guidelines
- Use
SegmentedControlfor one mode, view or filter for content that stays in place. UseTabswhen the choice swaps the panel it controls, andRadioGroupfor one persistent field value from a small set of options that all stay visible. - Pass
valueordefaultValue. 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 witharia-labelledbywhen visible text already labels it. Items take their name from their text; give an icon-only item anaria-label, mark its iconaria-hiddenand pair it with aTooltipthat shows the same words. - Keep the caller's value type.
SegmentedControl<Value>andSegmentedControlItem<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
RadioGroupwithRadioIteminstead when the options need a custom single-choice surface, such as separate filter pills.
Anatomy
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.
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.
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.
Keyboard
| Key | Action |
|---|---|
| Tab | Moves focus into the control on the selected item, then out of it. |
| Right arroworDown arrow | Moves focus to the next enabled item and selects it, wrapping at the end. |
| Left arroworUp arrow | Moves 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.
| Prop | Type | Default | Details |
|---|---|---|---|
defaultValue | Value | No default | |
value | Value | No default | |
className | string | ((state: RadioGroupState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, RadioGroupState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: RadioGroupState) => React.CSSProperties | undefined) | No default | |
disabled | boolean | false | |
readOnly | boolean | false | |
required | boolean | false | |
name | string | No default | |
form | string | No default | |
onValueChange | ((value: Value, eventDetails: BaseRadioGroup.ChangeEventDetails) => void) | No default | |
inputRef | React.Ref<HTMLInputElement> | No default | |
Valid prop combinations:
defaultValue: Value,value?: undefinedvalue: Value,defaultValue?: undefined
| Attribute | Description |
|---|---|
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.
| Prop | Type | Default | Details |
|---|---|---|---|
nativeButton | boolean | true | |
className | string | ((state: RadioRootState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, RadioRootState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: RadioRootState) => React.CSSProperties | undefined) | No default | |
value required | Value | No default | |
disabled | boolean | No default | |
required | boolean | No default | |
readOnly | boolean | No default | |
inputRef | React.Ref<HTMLInputElement> | No default | |
| Attribute | Description |
|---|---|
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). |