Skip to the page
TACTILE UI

Kit part · Knobs

Knob

A rotary control for continuous or stepped values where space is square. Its knurl and pointer turn; its light does not.

Element
<tui-knob>
Needs
kit.css + kit.mjs
Rules
knob.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

Gain
Small · 56px
Level
Large · 76px, 21 ticks
Tone
Black cap on any finish
Reserve
Stepped · 5% detents
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

PartMinimumMiddleMaximumFocus
Finish cap
Black cap

Graphite

PartMinimumMiddleMaximumFocus
Finish cap
Black cap
03

API

NameKindValuesWhat it does
min · max · step · valueattribute0 · 100 · 1 · minThe range and the start value. Values snap to the step.
labelattributerequiredBecomes the aria-label. Also print it under the knob in a .tui-label.
unitattributee.g. "%", "dB"Added to aria-valuetext: “62 %”.
labelsattributee.g. "Hobby, Team, Business"A name for each step from min, spoken instead of the number: a detented selector says “Team”, not “1”. Print the names round it too.
ticksattribute11Printed ticks around the 270° sweep; the ends and the centre are long. 11 for ±10, 21 for 0–100.
nameattribute—Form-associated: the value posts with the form under this name.
data-knob="black"attribute—A black cap, whatever the finish around it. (data-finish only ever names a finish.)
--sizeCSS property64pxCap diameter. The element is 1.45 × this, to hold the ticks. 56–76px.
--turnCSS propertyset by scriptThe angle, −135° to 135°. Read it; the knob writes it.
--k-hi · --k-mid · --k-loCSS propertyset per finishThe cap’s spun-metal tones.
.valuepropertynumberRead or set the value; setting it does not fire events.
input · changeeventbubblesinput while turning; change on release, and after each key or wheel step.
Dragpointer180px end to endUp or right turns it up. Shift: five times finer.
Arrows · PageUp/PageDown · Home/Endkeyboard±step · ±10% · min/maxUp and Right turn it up. The wheel steps it while it has focus.
.tui-controlclasswrapperStacks the knob, its printed label and an <output> in a column.
04

Markup

<div class="tui-control">
  <tui-knob label="Treble" name="treble" min="-10" max="10" step="1" value="3" ticks="11"></tui-knob>
  <span class="tui-label">Treble</span>
  <output>3</output>
</div>
import '/kit/kit.mjs';   // defines <tui-knob>

const knob = document.querySelector('tui-knob[name="treble"]');
const out = knob.parentElement.querySelector('output');
knob.addEventListener('input', () => { out.textContent = knob.value; });
knob.addEventListener('change', () => save(knob.value));   // on release

Needs kit.css and kit.mjs. How to install the kit.

05

Accessibility

  • It is a role="slider" with aria-valuemin, aria-valuemax, aria-valuenow and a aria-valuetext that includes the unit.
  • Reached with Tab; every value is reachable from the keyboard, so dragging is never required.
  • The wheel only turns it while it has focus, so scrolling the page never changes a setting by accident.
  • Show the value in an <output> under the label; do not rely on the pointer’s angle alone.
06

How it’s built

The only custom element in the kit. kit.mjs draws the ticks as an inline SVG and builds four layers: the knurl (a repeating conic gradient), the sheen (a fixed linear gradient, bright toward the lamp), the spun cap (a conic gradient with a bow-tie highlight and fine radial rings), and the pointer. Only the knurl and the pointer rotate, by --turn; the sheen, the highlight and every shadow stay where the lamp puts them. It is form-associated through ElementInternals.

07

Rules

knob.rules.mdIn the brain

Never draw a sheen that turns: the lamp is above left, and it stays there.

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

Fader

A continuous value along a line: a native range whose cap rides in a slot cut into the plate, with a printed scale.

Latency p95182ms

Readout

A printed label over a value: key figures, with the unit small and the change in words.

02:52min

LCD

A value that changes, on grey-green liquid crystal, with a ghost of the unlit segments behind it: clocks, battery, counters.

Docs
Finish
Volume