SegmentedControl
A row of two to five segments, exactly one of them chosen, for switching views or ranges.
Stability: experimental
Props
| Prop | Type | Default | Means |
|---|---|---|---|
label | string | The control's accessible name. | |
options | { value: string; label: string; icon?: string }[] | The segments. | |
value | string | bindable("") | The chosen segment's value. Bind it with bind:value={name}. |
disabled | boolean | false | No segment can be chosen. |
States
| State | Looks like |
|---|---|
chosen | A raised surface tile with ink text and a small shadow. |
focused | The focus outline on the segment. |
disabled | 50% opacity. |
Accessibility
| role | radiogroup, each segment a radio with aria-checked |
| name | The label prop; each segment by its text. |
| focus | One Tab stop for the group: the chosen segment, or the first segment when none is chosen. The other segments are left out of the Tab order. |
| keyboard | ArrowDown and ArrowRight move to the next segment and choose it, ArrowUp and ArrowLeft to the previous one, wrapping at the ends and skipping disabled segments. Enter or Space chooses the focused segment. |
Theme tokens
color.raised color.surface color.ink color.muted shadow.sm space.1 space.3 radius.md radius.sm text.caption
Example
<SegmentedControl label="View" options={views} bind:value={view} />