Skip to content

Meter

A role="meter" gauge for a measurement within a known range (disk, battery, score), with optional low/high thresholds.

It looks like Progress — a value in a range — and differs only in meaning: a meter is a level right now (a snapshot), a progressbar advances toward completion. Same anatomy, different announcement to assistive tech.

low and high say where the bands are; optimum says which band is the good one. A battery is good when it is full, so the default (optimum = max) is right. Disk usage is good when it is empty, so optimum={0} flips the judgement — and with it the colour, because the fill is coloured by how good the value is (data-quality), not by which band it sits in (data-level, still exposed as a styling hook).

<Meter value={90} label="Battery" low={20} high={60} />
<Meter value={90} label="Disk usage" low={50} high={80} optimum={0} />

Both read 90, and they are not the same news. Themeable per judgement with --ds-meter-fill-optimal | -suboptimal | -poor.

<script>
import Meter from "@invisible-ui/svelte/Meter.svelte";
</script>

In Elements:

<ds-meter label="Disk usage" value="72" low="50" high="80" optimum="0"></ds-meter>
PropTypeDefaultDescription
valuenumber0Current measurement.
minnumber0Range bounds.
maxnumber100Range bounds.
lownumber | undefinedundefinedThreshold marks (tint the fill).
highnumber | undefinedundefinedThreshold marks (tint the fill).
optimumnumber | undefinedundefinedWhere the good end of the scale is. Defaults to max, so more reads as better; set it near min for a measure where less is better.
label *string—Accessible name.
  • role="meter" with aria-valuenow/min/max. Not a progress bar — use Progress for task completion.
<Meter value={72} label="Disk usage" low={25} high={80} optimum={0} />

In React, useMeter gives the same props to markup of your own:

<Meter value={72} label="Disk usage" low={25} high={80} optimum={0} />

Themeable via --ds-meter-*.