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.
Which end is the good end
Section titled “Which end is the good end”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.
Import
Section titled “Import”<script> import Meter from "@invisible-ui/svelte/Meter.svelte";</script><script setup> import { Meter } from "@invisible-ui/vue";</script>import { Meter } from "@invisible-ui/react";<script type="module"> import "@invisible-ui/elements/define";</script>
<ds-meter></ds-meter>In Elements:
<ds-meter label="Disk usage" value="72" low="50" high="80" optimum="0"></ds-meter>| Prop | Type | Default | Description |
|---|---|---|---|
value | number | 0 | Current measurement. |
min | number | 0 | Range bounds. |
max | number | 100 | Range bounds. |
low | number | undefined | undefined | Threshold marks (tint the fill). |
high | number | undefined | undefined | Threshold marks (tint the fill). |
optimum | number | undefined | undefined | Where 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. |
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | 0 | Current measured value. |
min | number | 0 | Minimum value. |
max | number | 100 | Maximum value. |
low | number | undefined | Upper bound of the "low" range. |
high | number | undefined | Lower bound of the "high" range. |
optimum | number | undefined | Where 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 for the meter (required). |
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | — | Current measured value. |
min | number | — | |
max | number | — | |
low | number | — | Upper bound of the "low" band. |
high | number | — | Lower bound of the "high" band. |
optimum | number | — | Where 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 for the meter. |
| Attribute | Reactive | Description |
|---|---|---|
label * | yes | the accessible name |
value | yes | 0 by default |
min | yes | 0 by default |
max | yes | 100 by default |
low | yes | the upper bound of the low band |
high | yes | the lower bound of the high band |
optimum | yes | where the good end of the scale is; max by default |
Reactive attributes re-render the element when they change after the first render.
Properties: value, min, max, low, high, optimum.
Accessibility
Section titled “Accessibility”role="meter"witharia-valuenow/min/max. Not a progress bar — use Progress for task completion.
Example
Section titled “Example”<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-*.