Skip to content
GitHub (opens in a new tab)

SegmentedControl

Choose one of a few visible options in a joined track. role=radiogroup, sm or md, icons optional.

stableMoleculecontracts/segmentedcontrol.json

Preview

SegmentedControl

One choice in a joined track. Controlled or uncontrolled, sm or md, icons optional. role=radiogroup with arrow keys.

Master

Click a segment or focus it and use the arrow keys. Variants shows sm, icons and a disabled item.

Usage

Pass value and onChange for a controlled group, or defaultValue for uncontrolled. Arrow keys move the checked segment. Disabled segments are skipped.

Do's

  • Two to five mutually exclusive options that should stay visible, such as billing period or density
  • A compact switch where each option is a short label, with or without an icon

Don'ts

  • Switching panels of content — use Tabs
  • Plans or options that need a description or price — use TileGroup
  • More than a handful of options — use Select
  • Independent booleans — use Checkbox
<SegmentedControl
  ariaLabel="Billing"
  size="md"
  value="month"
  onChange={() => {}}
  items={[{ value: 'month', label: 'Monthly' }, { value: 'year', label: 'Yearly' }]}
/>

When to use

  • Two to five mutually exclusive options that should stay visible, such as billing period or density
  • A compact switch where each option is a short label, with or without an icon

When not to use

  • Switching panels of content — use Tabs
  • Plans or options that need a description or price — use TileGroup
  • More than a handful of options — use Select
  • Independent booleans — use Checkbox

What an agent reads

import { SegmentedControl } from "agentic-ds-kit";
must
  • role=radiogroup on the root and role=radio on each segment
  • aria-checked reflects the selected segment
  • describedBy lands on the radiogroup as aria-describedby
  • Roving tabindex: one segment is tabbable
  • Arrow keys, Home, and End move selection and focus, skipping disabled segments
  • Disabled segments stay visible and are not selectable
  • focus-visible kit ring
  • An item's optional tooltip is a kit Tooltip that opens on hover and on keyboard focus and describes that segment while open
  • The old thumb fades out while the new one fades in, in place (opacity only). No motion under prefers-reduced-motion
defaults
  • size md
  • fullWidth false
  • disabled false
stops if
  • Do not invent SegmentedControlItem as a separate component
  • Do not use Tabs variant=segmented when the choice is a form value
  • Do not use raw hex
  • Do not ship the group without ariaLabel

From contracts/segmentedcontrol.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
describedBystringNo—Id(s) for aria-describedby on the radiogroup. Field passes its hint or error id.
ariaLabelstringYes—Names the radiogroup. There is no separate legend.
itemsarrayYes—tooltip is an optional short hint in a kit Tooltip around that segment, shown on hover and on keyboard focus; the label stays the radio's name. Omit it and the segment renders as before.
valuestringNo—controlled
defaultValuestringNo—uncontrolled
onChangefunctionNo—(value: string) => void
sizesm | mdNomd—
fullWidthbooleanNofalseStretches the track to its container and splits it into equal segments, e.g. a filter above a list pane.
disabledbooleanNofalseLocks the whole group.
  • Component
    →

    Tabs

    Switch between related views in place.

  • Block
    →

    Plans

    A whole pricing section: plan cards, a Monthly / Yearly switch and the questions people ask before they buy.

  • Component
    →

    TileGroup

    Selectable cards for a plan or option picker.

  • Component
    →

    Select

    Choose one or several options from a list.