Segment

A single-choice control that shows every option at once.

Segments is a horizontal set of mutually exclusive options, all visible so the user can weigh them without opening anything. Use it for two to five short, stable choices — a view or a filter — and switch to a Select once the list grows or changes.

Examples

Text only

<Segments aria-label="View" defaultValue="all">
<Segment value="all">All</Segment>
<Segment value="active">Active</Segment>
<Segment value="inactive">Inactive</Segment>
</Segments>

defaultValue selects a segment for uncontrolled use; pass value with onChange when the parent owns the selection. The animated indicator slides between segments as the value changes.

With icons

<Segments aria-label="Chart" defaultValue="bars">
<Segment value="bars" startIcon={<BarChartIcon />}>
  Bars
</Segment>
<Segment value="line" startIcon={<ChartUpIcon />}>
  Line
</Segment>
</Segments>

startIcon sits before the label and tightens the leading padding; the segment sizes it and dims it until selected. Keep the text alongside it — an icon-only segment leaves the choice ambiguous.

When to use

Use Segments for two to five short, stable, mutually exclusive options that should all stay visible — a view or a filter.

Use something else when:

  • The list is longer, changes at runtime, or can be empty. Use Select.
  • Each option switches a whole panel of content. Use Tabs.
  • It is a single on/off setting. Use Switch.

Usage

Do

Keep labels to one word and give one segment a defaultValue so the control always shows a current choice.

Don't

Use Segments when a choice can be empty or the options change at runtime. That is a Select, which allows no selection and a scrolling list.

Props

Segments

PropTypeDefault
children

The children of the component. A function may be provided to alter the children based on

TypeChildrenOrFunction<RadioGroupRenderProps>Default—
className

The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the

TypeClassNameOrFunction<RadioGroupRenderProps>Default—
defaultValue

The default value (uncontrolled).

Typestring | nullDefault—
isDisabled

Whether the input is disabled.

TypebooleanDefault—
isInvalid

Whether the input value is invalid.

TypebooleanDefault—
isReadOnly

Whether the input can be selected but not changed by the user.

TypebooleanDefault—
isRequired

Whether user input is required on the input before form submission.

TypebooleanDefault—
orientation

The axis the Radio Button(s) should align with.

Type"horizontal" | "vertical"Defaulthorizontal
validate

A function that returns an error message if a given value is invalid.

Type((value: string) => true | ValidationError | null)Default—
validationBehavior

Whether to use native HTML form validation to prevent form submission

Type"native" | "aria"Default'native'
value

The current value (controlled).

Typestring | nullDefault—

Segment

PropTypeDefault
valuerequired

The value of the radio button, used when submitting an HTML form.

TypestringDefault—
borderRadiusTypenumberDefault—
children

The children of the component. A function may be provided to alter the children based on

TypeChildrenOrFunction<RadioGroupRenderProps>Default—
className

The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the

TypeClassNameOrFunction<RadioGroupRenderProps>Default—
inputRef

A ref for the HTML input element.

TypeRef<HTMLInputElement | null>Default—
isDisabled

Whether the radio button is disabled or not.

TypebooleanDefault—
startIconTypeChildrenOrFunction<RadioRenderProps>Default—

Accessibility

Segments wraps React Aria's RadioGroup and each Segment is a Radio, so the group is one tab stop and the arrow keys move between options. Name the group with a visible label or aria-label, and give every Segment a value.

Unselected labels use fg-muted, which meets 4.5:1 contrast against the track in light and dark themes, so every option stays readable before it is chosen.

When the reader prefers reduced motion, the indicator jumps to the new segment instead of sliding, and the label colour changes at once.