Segmented control
Radio inputs in one tinted track; the chosen one is a raised thumb.
Examples
Segmented
Full width · data-fill
Anatomy
.segmented | The track: one tint, inset so the thumb sits inside it at the control height. Short of room, segments wrap onto another row instead of shrinking. Give it role="radiogroup" and an aria-label. |
> label | One per segment. |
label > input[type=radio] | Covers the segment, invisible. All inputs share a name. |
label > span | The segment: a bare, muted label. Checked, it is a thumb with a small shadow (the white surface in light, the press tint in dark), in text ink (tone ink under data-tone); under prefers-contrast: more it also takes the 2px edge. Under data-fill (up to six options, shared equally) the thumb glides from one choice to the next. |
API
| Attribute | Values | Description |
|---|---|---|
data-size | sl | One control size smaller (s) or larger (l): height and type step together. Default sits between. |
data-fill | boolean | Spans the row instead of hugging its labels; the segments share it equally, their text centred. For inspectors and narrow panels. |
checked | boolean | On one input: the segment that starts selected. With none checked, no segment is on. |
data-tone | boolean |
Accessibility
- It is a native radio group, so screen readers announce "Week, radio button, 2 of 3" without extra markup.
role="radiogroup"with anaria-labelnames the group; the radios already group byname.- Focus draws the ring on the segment's span, not on the hidden input.
- The checked segment never relies on colour alone: it also carries the 2px edge. In forced colours it takes the system highlight.
| Key | Effect |
|---|---|
| ← / → | Moves the selection to the previous or next segment. |
| Tab | Enters the control at the checked segment; the control is one tab stop. |