Components
Segmented control
Switches between two to four views of the same thing. The bone indicator glides between options; it never jumps, and the text inverts as it arrives.
Overview
Showing the day
Anatomy
- 1TrackA hairline box with square corners. Square, because it’s a switch, not a button.
--au-border-hairline - 2IndicatorA bone block that slides to the selected option over 600ms on the glide curve.
--au-bg-inverse - 3OptionLabel type. Inverts to ink on bone when selected. Trailing tracking trimmed so it centres true.
.au-type-label
Usage
Use it to switch views of the same content, with short, parallel labels.
Don’t use it for actions or for more than four options. Actions are buttons; long lists are navigation.
Accessibility
- A radio group. The track is
role="radiogroup"with a requiredlabel; each option is a radio. - One tab stop. Tab lands on the selected option; arrow keys move selection and focus together, and wrap.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| options* | { value: string; label: string }[] | — | Two to four options. |
| value* | string | — | The selected option. |
| onChange* | (value: string) => void | — | Called with the new value. |
| label* | string | — | Names the group for assistive technology. |
Tokens
| Token | Value | Used for |
|---|---|---|
| --au-bg-inverse | → stone.50 · #EDEBE5 | Fills that have been committed, like a held button. |
| --au-text-inverse | → night.950 · #08090A | |
| --au-text-label | → stone.500 · #86847D | Uppercase labels. 5.3:1. |
| --au-border-hairline | → night.750 · #1E2024 | Default 1px structure. |
| --au-dur-glide | 600ms | |
| --au-ease-glide | cubic-bezier(0.32, 0.72, 0, 1) | Decelerates into place. Anything that moves or changes size. |
Code
const [view, setView] = useState('day');
<SegmentedControl
label="Prototype state"
value={view}
onChange={setView}
options={[
{ value: 'day', label: 'Thursday' },
{ value: 'quiet', label: 'A quiet day' },
]}
/>