Skip to the page
Tactile UI

Key

Every button, and every link that acts like one: a cap on a skirt that drops below the plate when pressed.

Element
<button> · <a>
Needs
kit.css
Rules
key.rules.md · 7
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

Contrast · the one action
Plain
Flat · printed text that acts
Danger · confirm in a dialog
Sizes · sm 28 · 36 · tap 44 · lg 46
Wide · a list of choices, logo first
With a lamp in the cap
A link

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

PartRestHoverPressedLatchedFocusBusyDisabled
Key
Contrast
FlatNone

Graphite

PartRestHoverPressedLatchedFocusBusyDisabled
Key
Contrast
FlatNone

API

NameKindValuesWhat it does
.tui-keyclassA plain key: a raised cap on a 2px skirt, 36px tall.
.tui-key--primaryclassThe contrast cap: the one action on a surface that matters most.
.tui-key--flatclassNo cap at all: printed text that acts. For backing out.
.tui-key--dangerclassRed printing on a plain cap, for destructive actions.
.tui-key--sm · --lgclass28px · 46pxSmall in tables and panel heads; large in heroes. Skirts scale with the cap: 1.5px, 3px.
.tui-key--tapclass44pxThe fingertip size: for keys on a form people fill on a phone. Same skirt and printing as the plain key; works in a combo, beside a .tui-input--tap.
.tui-key--fingerclass44px on touchA small key on a page grows to 44px under a finger; under a mouse it stays as it is. Every key already has a 44px press area on touch.
.tui-key--wideclassThe key takes its row and its words start at the left, after a leading logo or icon (an <svg> first inside it). For a short list of choices that each go somewhere, one under the other.
.tui-key--icon · --roundclassKeys with an icon and no words: see the icon key.
aria-pressedattribute"true" · "false"A latching key. “true” holds it down below the plate.
disabled · aria-disabledattribute45% opacity and no travel. Use aria-disabled="true" on links.
aria-busyattribute"true"70% opacity and a waiting cursor. The key keeps focus.
data-tipattributetextA one-line name shown on hover and focus. Required on icon keys, with an aria-label.
data-materialattributealuminium · graphite · porcelain · black-anodised · titanium · bakelite · anodised-blue · anodised-greenWhat the cap, its skirt and its printing are made of, apart from the page’s finish; the contrast key takes the material’s own. On the key or on the device around it. Anodised blue and green go on a whole device only.
--h · --skirtCSS property36px · 2pxCap height and skirt depth. The size modifiers set both.
.is-hover · .is-down · .is-focusclassForced states, for documentation and specimens only.
Enter · SpacekeyboardNative button behaviour. The key presses on :active, so it drops under a finger, a mouse or a key.

Markup

<button class="tui-key tui-key--primary">Start recording</button>
<button class="tui-key">Save preset</button>
<button class="tui-key" aria-pressed="false">
  <span class="tui-lamp" data-on></span>Monitor
</button>
<button class="tui-key tui-key--flat">Cancel</button>

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

Accessibility

  • Use a real <button>, or an <a> for navigation. Both are reached with Tab and keep the 2px focus ring, 3px away.
  • Icon keys need an aria-label; with kit.mjs the data-tip becomes a real tooltip, read after the name, so keep the two close in meaning.
  • A latching key announces its state through aria-pressed. The lamp in its cap is a second signal, never the only one.
  • The contrast cap holds 13:1 or better against its printing in aluminium and graphite.

How it’s built

Two backgrounds and a stack of box-shadows, no images. The cap is a linear gradient of --tui-face-hi under a radial highlight from above; the skirt is a hard 2px shadow in --tui-skirt, with a contact shadow and a soft one below it. Pressing moves the cap down by exactly the skirt and swaps the shadows for --tui-pressed: the plate’s edge now shades the cap’s top and sides. 70ms, one easing curve.

Rules

key.rules.mdIn the brain

One contrast key per surface. The label says what happens: “Erase reel”, not “Submit”.

7 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.

Icon key

A key with an icon and no words, square or round: transport, power, the small tools. Its aria-label names it; a tip shows the name.

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.

Dialog

A decision that must be made now: a native dialog with a question, one sentence of consequence, a way back and the act.