Skip to the page
TACTILE UI

Kit part · Radio groups · Toggles & switches

Segmented control

A row of keys in a tray with one pressed down: pick a view, a range or a mode and it applies at once. It is the kit’s selector without the lamps, with sizes, a full-width row and icon segments.

Element
.tui-seg[role=radiogroup]
Needs
kit.css
Rules
segmented.rules.md · 5
Finishes
Aluminium · Graphite · Porcelain · Black
Volumes
Tactile · Quiet
On this page
  1. Variants
  2. Every state, at once
  3. API
  4. Markup
  5. Accessibility
  6. How it’s built
  7. Rules
  8. Related parts
01

Variants

Three words
Small · --sm
Large · --lg
Full width · --block
Icons · --icon
One unavailable
Charging
A fieldset with a legend
With lamps · the selector
02

Every state, at once

Both finishes, side by side. Hover, pressed and focus are forced with .is-hover, .is-down and .is-focus; checked and disabled are real.

Aluminium

PartUpHoverPressedSelectedFocusDisabled
Segment

Graphite

PartUpHoverPressedSelectedFocusDisabled
Segment
03

API

NameKindValuesWhat it does
.tui-segclasson a div or fieldsetThe tray: a recess with 3px inside and 9px corners, and a key per segment.
.tui-seg--plainclass—No lamp on each key. Use it for views and settings; without it each key carries the selector’s amber lamp.
--sm · --lgclass24 · 38 pxSizes: a 30px key by default. The tray’s corner follows the key’s, plus the 3px gap.
--blockclass—Full width, the segments sharing it equally.
--iconclass—Square segments for icons. Each input needs an aria-label.
role="radiogroup" · aria-labelattributeon the trayNames the group. Or make the tray a <fieldset> and give it a <legend>, which is not drawn.
label > input[type=radio] + spanelementper segmentA real radio, hidden, and its printed key. The checked one is pressed below the plate.
disabledattributeon an inputThat segment at 45%, no movement; the arrow keys skip it.
changeeventon the inputAs any radio: fires on the one that became checked.
← → · ↑ ↓keyboardnativeMove to the neighbour and choose it, wrapping at the ends; Tab enters and leaves the group as one stop.
.is-hover · .is-down · .is-focusclasson the labelDocs only: force a state.
04

Markup

<div class="tui-seg tui-seg--plain" role="radiogroup" aria-label="Range">
  <label><input type="radio" name="range" value="day"><span>Day</span></label>
  <label><input type="radio" name="range" value="week" checked><span>Week</span></label>
  <label><input type="radio" name="range" value="month"><span>Month</span></label>
</div>

<!-- Full width, and a size -->
<div class="tui-seg tui-seg--plain tui-seg--block tui-seg--lg" role="radiogroup" aria-label="View">…</div>

<!-- Icons in place of words: each is named -->
<div class="tui-seg tui-seg--plain tui-seg--icon" role="radiogroup" aria-label="Layout">
  <label><input type="radio" name="layout" value="list" aria-label="List" checked><span><svg …/></span></label>
</div>
// Nothing to load: radios, native. Read the choice as you would any radio group.
document.querySelectorAll('input[name="range"]').forEach((r) =>
  r.addEventListener('change', () => show(r.value)));

Needs kit.css only, no script. How to install the kit.

05

Accessibility

  • It is a radio group, so a screen reader hears its name, “Range, 2 of 4, Week, selected”, and the arrow keys, Tab and the wrap at each end are the browser’s.
  • The tray carries role="radiogroup" and an aria-label, or is a fieldset with a legend; both name the group.
  • The pressed key is shown by depth and a heavier ink, not colour; without the lamps there is no colour to lose in either finish.
  • A segment with only an icon needs an aria-label on its input, and one that is unavailable stays in the row, disabled, so the choices do not shift.
  • Focus is the kit’s 2px ring on the segment’s key, drawn from the hidden input.
  • It changes something at once. A choice that needs a confirmation is a form with a key, not this.
06

How it’s built

The tray and the key are the kit’s recess and cap, already in the selector; this part is the selector with its lamps off and three more things. A pressed key drops the height of its skirt into the tray and takes the pressed light, so the plate’s edge shades its top. Sizes change the key and the tray together, and each keeps the corners concentric: 5, 6 or 8px of key plus the 3px gap is 8, 9 or 11px of tray. The radios are ordinary inputs, absolutely positioned and invisible, with the printed key as the span that follows each; there is no script at all.

07

Rules

segmented.rules.mdIn the brain

Two to five short words, one down at a time, applied the moment you press.

5 rules in this file, with the foundations they rest on and the anti-patterns that break them. Full rules ship in the brain with the Pass.

08

Selector

One mode of two to five: latching keys in a tray, one down at a time, each with a lamp that lights when chosen.

Tabs

Views of the same thing, switched in place: keys in a tray, the chosen view a raised cap.

Radio

One choice from a short list in a form: small round keys in a fieldset, the chosen one pressed with a printed dot.

Docs
Finish
Volume