Skip to the page
Tactile UI

Switch

On or off, applied the moment it moves. A native checkbox with a ridged thumb in a slot that lights green when on.

Element
<input type="checkbox">
Needs
kit.css
Rules
switch.rules.md · 5
Finishes
Aluminium · Graphite · Chalk · Carbon · Oak · Walnut · Porcelain · Black · Daylight · Night · Paper · Phosphor · E-paper · AMOLED
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

Variants

Lamp rocker · tui-rocker tui-rocker--lamp · 80 × 34, no extra markup
The plain switch · tui-switch · 48 × 26
In a settings row
Heat pump
In a table cell
With a second line

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

PartOffOnFocusDisabled offDisabled on
Switch

Graphite

PartOffOnFocusDisabled offDisabled on
Switch

API

NameKindValuesWhat it does
.tui-switchclasson <input type="checkbox">A 48 × 26 slot with a ridged thumb that slides 16px.
.tui-rocker--lampclasswith .tui-rockerThe lamp rocker: the same rocker in an 80 × 34 bezel with a lamp lens right of the cap, lit green when on. Costs 32px more width than the rocker (the switch is 48 × 26) and no extra markup: <code>&lt;input type="checkbox" role="switch" class="tui-rocker tui-rocker--lamp"&gt;</code>. On a touch screen it takes a 44px press area. The marks are the IEC | and O, nothing to translate.
checkedattributeOn: the thumb slides right and the slot lights green.
data-materialattributealuminium · graphite · porcelain · black-anodised · titanium · bakelite · anodised-blue · anodised-greenWhat the thumb is made of, apart from the page’s finish. The slot is cut in the plate: it keeps the finish and still lights green. On the switch or on its device. Anodised blue and green go on a whole device only.
disabledattribute45% opacity, no pointer.
name · valueattributePosts with a form like any checkbox.
changeeventNative. Apply the setting here, at once.
.is-focusclassForced focus ring, for specimens.
SpacekeyboardToggles, as any checkbox.

Markup

<label class="tui-choice">
  Phantom power
  <input type="checkbox" class="tui-switch" checked>
</label>

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

Accessibility

  • Wrap the words and the switch in one <label class="tui-choice"> so the text names it and the whole row is clickable.
  • In a table, where there is no room for words, give it an aria-label that names the thing it powers: “Heat pump power”.
  • On is also the thumb’s position, not only the green slot.
  • Keyboard: a native checkbox drawn as a switch. Tab focuses it and Space switches it; a disabled switch is skipped.

How it’s built

An appearance: none checkbox. The slot is the kit’s recess; the thumb is an ::after with a raised light and a ridged grip drawn by one repeating gradient. Checked, the thumb translates 16px over 180ms and the slot fills with a mix of --tui-green and the well. No script, no images.

Rules

switch.rules.mdIn the brain

If the change needs a Save, it is not a switch: use a check key.

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.

Rocker

A heavier on/off for power, mains and arming: a cap that pivots in a black bezel, printed | and O.

Check

An option in a form: a small square key that presses below the plate when chosen, with a tick printed on it.

Reel 342:10
Mixed0:30

Table

The TUI table is rows of data with printed column labels, figures right-aligned in columns, and status in lamps with words.