Segmented control
A segmented control joins two to five short values in one row, and one of them is always chosen. It changes the view around it, or a setting with a few values, the moment it is pressed.
What it is
When to use it
Use it for closely related values that change the same thing, such as the period of the placements dashboard or who picks up new applications. The choice applies at once.
To move to another page or section, use tabs or links, and to run an action, use buttons. When there are more than five values, or the labels need more than a word or two, use radio buttons or a select.
Anatomy
Each segment is as wide as its word, with room at each side. The chosen one is solid brand blue with white words. A gradient would make it read as a button to press, not a value that is set.
- Track height with a mouse
- 36 px
- Track height on touch
- 48 px
- Space around and between segments
- 2 px
- Track fill
- control gray
- --surface-control
- Track radius
- 10 px
- Segment height
- 32 px, 44 px on touch
- Segment radius
- 8 px
- --radius-lg
- Segment width
- its word and 12 px at each side, at least 44 px
- --space-3
- Label
- 13 px on a 20 px line, weight 700
- --text-muted
- Chosen segment
- brand blue with white words
- --brand-true
States
The words that are not chosen are gray, and darken under the pointer.
When the whole control is disabled, every segment fades and the chosen one keeps its blue, so the value still shows. A single segment is never disabled: a value that cannot be chosen leaves the control.
- At rest
- Pointer over Month
- Keyboard focus on Week
- Disabled
- At rest
- Pointer over Month
- Keyboard focus on Week
- Disabled
- Label under the pointer
- full ink, mouse only
- --text
- Chosen label
- white
- --on-brand
- Focus ring
- 2 px, in the space around the segment
- --focus-ring
- Disabled
- every segment at 60 percent
Width and small screens
On screens narrower than 640 px the control fills the width of its container and the segments share it. On wider screens each segment is as wide as its word.
The control does not scroll and does not wrap. At 360 px, check that the longest label fits its segment. If it does not, use a select.
Behavior and keyboard
The chosen fill slides to its new segment in 150 milliseconds. With reduced motion, it moves without sliding. If saving a setting fails, the choice goes back and a message says why.
A screen reader hears the control's name, the segment, its position and whether it is chosen.
- Tab
- reaches the chosen segment
- Arrow keys
- move to the next segment and choose it, wrapping at the ends
- Home and End
- choose the first and the last segment
Writing the labels
Label segments with nouns in sentence case, a word or two each: Today, Week, Month.