SegmentedControl
moleculesSingle-select row of segments with a sliding thumb: labelled filter pills with counts, or compact icon toggles, with radiogroup keys.
Library filter and view
filter pills with count and bind:value, plus a variant="icon" view toggle on the same row; onchange fires after a selection.
Wrap, scroll, block and collapsing labels
wrap folds segments onto rows; scroll keeps one row that pans; a pill wider than its box falls back to scrolling; block shares the width equally; collapseLabels="mobile" | "container" hides text under 48rem or in a narrow container.
States and counts
a disabled segment is skipped by arrow keys; no initial value picks the first enabled one; string counts render verbatim.
Toolbar, custom segments and justify
control height-matches Button and Input siblings; box lines an icon toggle up with square buttons; the option snippet renders each segment; justify pins the control in a flex row.
Filter in the URL
href={(value) => string} renders each segment as a real link with aria-current; urlState keeps the ?filter= param so the filter survives a reload and can be shared.
Square tiles and toned selection
shape="square" lays the options out as small-radius tiles with a neutral ring; a per-option tone or color rings the selected one in its colour.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
options required | SegmentOption[] | — | |
value bindable | string | — | |
onchange | (value: string) => void | — | Fires after a selection (click or keyboard). |
href | (value: string) => string | — | Segments become real links (`<a aria-current>`): middle-click opens the segment's URL in a new tab. |
justify | 'start' | 'end' | — | Pin the control to the start/end of a flex row. |
wrap | boolean | false | Allow segments to wrap onto multiple lines. |
variant | 'pill' | 'icon' | 'pill' | |
shape | 'pill' | 'square' | 'pill' | `square`: separate small-radius tiles with a neutral ring instead of a filled track. |
size | ControlSize | — | |
control | boolean | false | Uniform toolbar control height (like Popover/Button `control`) so the whole segmented control height-matches its siblings; follows a sized `Cluster`. |
box | boolean | false | Adopt `--control-height-default` so an icon toggle lines up with `Button square` / `box` siblings. |
label | string | 'Options' | |
collapseLabels | 'never' | 'mobile' | 'container' | 'never' | |
scroll | boolean | false | Single non-wrapping row that scrolls horizontally (scrollbar hidden). |
block | boolean | false | Fill the parent width, sharing it equally between segments. |
sound | boolean | true | Play UI sounds when enabled globally; false silences this instance. |
class | string | '' | |
option | Snippet<[SegmentOption, boolean]> | — |