SegmentedControl

A compact single-choice control for filters, view modes, and persistent preference choices.

Preview#

import {
  SegmentedControl,
  SegmentedControlCount,
  SegmentedControlItem,
  SegmentedControlLabel,
} from "raft-ui";

<SegmentedControl defaultValue="all" aria-label="Filter">
  <SegmentedControlItem value="all">
    <SegmentedControlLabel />
    <SegmentedControlCount />
  </SegmentedControlItem>
</SegmentedControl>

Segment items own icon sizing, label truncation, and count line-height. Compose plain icons, SegmentedControlLabel, and SegmentedControlCount unless a specific custom size is intentional.

Filters with counts#

View mode#

Search sort#

Preference choice#

Disabled state#

API#WIP

PropTypeDefaultDescription
valueTThe controlled selected item value.
defaultValueTThe initial selected value for uncontrolled use.
onValueChange(value: T) => voidCalled when a segment is selected.
aria-labelstringNative ARIA attribute naming the group for assistive tech. Set it when the group has no visible label.
disabledbooleanfalseDisables and dims the whole control.
namestringNative form field name passed to Base UI RadioGroup.
classNamestringAdditional classes on the group.
PropTypeDefaultDescription
valueTThe value this segment selects.
disabledbooleanfalseDisables this segment only.
...propsBase UI Radio.Root.Props<T>Native radio attributes plus Base UI radio behavior.
PropTypeDefaultDescription
...propsComponentPropsWithRef<"span">Segment label text.
PropTypeDefaultDescription
...propsComponentPropsWithRef<"span">Optional numeric badge or count shown after the label.