Skip to the page
Tactile UI

Kit part · Progress

Meter

A value inside a known range, read off an LED strip. The strip is a native meter element, so low, high and optimum are the browser’s own: the whole lit length takes the colour of where the value stands (green in the good region, amber next to it, red beyond), not the colour of the segment it has reached. The marks under the strip print where the regions begin, and cut lines across it show the same two places. Words say the state too.

Element
<meter class="tui-meter__strip">
Needs
kit.css
Rules
meter.rules.md · 6
Finishes
Aluminium · Graphite · 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

Seats open in 11 days. Want one email that morning?

Variants

31 GB Plenty free
31 GB
A good end that is low · storage
58 points Fair
58 points
A good end that is high · a score
26 °C Warm
26 °C
A good end in the middle · temperature
91 GB Nearly full
91 GB
No marks · --bare, with --lg
64 %
64 %
No thresholds · all optimum
60 GB Getting full
60 GB
Fewer segments · --n

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

PartGoodFairPoor
Storage
14 GB Plenty free
14 GB
72 GB Getting full
72 GB
93 GB Nearly full
93 GB

Graphite

PartGoodFairPoor
Storage
14 GB Plenty free
14 GB
72 GB Getting full
72 GB
93 GB Nearly full
93 GB

API

NameKindValuesWhat it does
div.tui-meterelement--lo and --hiThe meter and its label, value and state. Set --lo and --hi (0 to 1) to where the meter’s low and high fall, so the cut lines and marks agree with them.
.tui-meter__strip > meterelementmin max low high optimum valueThe native meter, drawn as the strip. It gives the screen reader its value and range and the browser the colour of the lit length.
.tui-meter__headelementlabel, value, stateA real label for the meter, the figure and the state in words, with a lamp that agrees (green, amber or red).
.tui-meter__marks > .tui-meter__markelement--at: 0 to 1A printed tick under the strip and its figure, at that fraction of the range. Add --cut for the two thresholds. The first and last lean away from the edge.
--nCSS property24The number of segments.
--lg · --baremodifiertui-meter--lg, --bareA taller strip; or the strip without its cut lines.
meterState(value, range) · meterRegion() · meterFraction()functionpureThe browser’s rule in code: "good", "fair" or "poor", which third of the range, and where in 0 to 1.
setMeter(root, value)functionneeds kit.mjsSets the native value, the lamp, the words from data-good, data-fair and data-poor, and fires tui-meter-change.

Markup

<div class="tui-meter" style="--lo:.5;--hi:.85"
     data-good="Plenty free" data-fair="Getting full" data-poor="Nearly full">
  <div class="tui-meter__head">
    <label class="tui-label" for="disk">Storage used</label>
    <span class="tui-meter__value">72 GB</span>
    <span class="tui-meter__state">
      <span class="tui-lamp" data-lamp="amber" data-on aria-hidden="true"></span>
      <span class="tui-meter__words">Getting full</span>
    </span>
  </div>
  <div class="tui-meter__strip">
    <meter id="disk" min="0" max="100" low="50" high="85" optimum="20" value="72">72 GB</meter>
  </div>
  <div class="tui-meter__marks" aria-hidden="true">
    <span class="tui-meter__mark" style="--at:0"><span>0</span></span>
    <span class="tui-meter__mark tui-meter__mark--cut" style="--at:.5"><span>50</span></span>
    <span class="tui-meter__mark tui-meter__mark--cut" style="--at:.85"><span>85</span></span>
    <span class="tui-meter__mark" style="--at:1"><span>100</span></span>
  </div>
</div>
import { setMeter, meterState } from '/kit/kit.mjs';

// Sets the native value, the lamp, the state's words and fires tui-meter-change.
setMeter(document.querySelector('.tui-meter'), 91);

meterState(91, { min: 0, max: 100, low: 50, high: 85, optimum: 20 });   // 'poor'
meterState(72, { min: 0, max: 100, low: 50, high: 85, optimum: 20 });   // 'fair'

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

Accessibility

  • The strip is a native <meter> with a real <label>, so a screen reader says “Storage used, meter, 72 of 100”, with the range and the value, and no ARIA is needed.
  • The state is said in words next to the strip (“Getting full”) with a lamp that agrees; the lit length changing colour is never the only sign. The marks and the cut lines are decoration for the eye and are hidden, since the thresholds are in the meter itself.
  • The words are the secondary ink, at least 4.5:1 on the plate, and the strip is a dark window whose edge is seen at 3:1 in every finish.
  • It takes no focus. The lit length eases for 120ms when it changes; under reduced motion it does not, and every figure is the same.
  • On a phone the strip and the marks scale to the width and the first and last marks stay on the plate, so there is no sideways scroll at 390px.

How it’s built

It is the ladder’s dark glass with the opposite idea in it. The ladder paints its segments by position, green then amber then red along its length, so it shows how far up a scale something is. The meter paints the whole lit length one colour, chosen by the native meter from low, high and optimum, so it shows whether the value is good: the same 40 on a strip whose good end is high is red and on one whose good end is low is green. The cut lines and printed marks are drawn from two custom properties, and the segment gaps are laid over the browser’s own bar.

Rules

meter.rules.mdIn the brain

Show where a value stands between a low and a high that matter: storage used, a score, a cabinet’s temperature, with the thresholds printed under the strip.

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

Ladder

An LED ladder for levels and load: green, then amber, then red, the way a recording level has always been read.

Progress

Progress through a task: ink filling a groove, never a coloured bar.

Battery

A cell outline with a terminal at one end, filled with lamp segments set into a recess, lit from the empty end. The lit segments are one lamp colour for the whole cell: green, amber below two fifths, red below a fifth. While it charges, the top lit segment breathes. The level is said in words too, so neither the colour nor the breathing is the only sign.

Lamp

The only colour in the kit: a lamp that is on. Green is on, amber is waiting, red is recording or failing, blue is linked, white is standing by. Always next to words.