Duolith docs

SegmentedControl

A row of two to five segments, exactly one of them chosen, for switching views or ranges.

Stability: experimental

Props

PropTypeDefaultMeans
labelstringThe control's accessible name.
options{ value: string; label: string; icon?: string }[]The segments.
valuestringbindable("")The chosen segment's value. Bind it with bind:value={name}.
disabledbooleanfalseNo segment can be chosen.

States

StateLooks like
chosenA raised surface tile with ink text and a small shadow.
focusedThe focus outline on the segment.
disabled50% opacity.

Accessibility

roleradiogroup, each segment a radio with aria-checked
nameThe label prop; each segment by its text.
focusOne 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.
keyboardArrowDown 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} />