Meter
ProA value on a known scale, such as storage used or a quota, with a warning past a threshold said in words, never by colour alone. Not an M3 component (@windmorph/react-pro).
import { Meter, MeterList } from '@windmorph/react-pro/charts';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Keyboard
None. A meter reports a level and takes no input, so it has no keys.
Screen reader
- Role
meter, from React Aria. AMeterListis alistwhose every row holds one.- Accessible name
- A meter's
labelnames it (aria-labelledby), as each row'slabeldoes in a list. AMeterListis named byaria-labeloraria-labelledby, or by the title of the Chart frame it sits in. - States announced
aria-valuenow,aria-valueminandaria-valuemax, with the words inaria-valuetextfromlabels.valueText: "75.6 GB of 100 GB", then the state's words fromwarningAtor pastmax("18 of 20, Close to the limit"). Past the limitaria-valuenowstays atmaxand the words give the real amount ("22 of 20, Over the limit"). An amount or a limit that isn't a number still gives numbers within the range, and the words say "No value".
- The figure, the track and the state's mark and words beside it are hidden from assistive tech (
aria-hidden), since the value text says them. Thenoteis read as it is, after the meter. - It isn't a live region: a new amount is read when someone reaches the meter, not announced. Announce a change that matters in a live region of your own.
- A meter's
aria-describedby,aria-detailsand description attributes go on themeter; a list's go on the list.
Focus
None. A meter is not focusable, and a MeterList adds no focus stops.
Touch target
None. A meter takes no presses, so it has no touch target.
Motion
- The fill grows from the start the first time the meter comes into view, as its number counts up from
min; a new amount moves both, on the theme's default spatial spring (--wm-meter-fill-duration,--wm-meter-fill-easing). Under reduced motion both change at once. - A meter on screen as the page loads shows its final picture from the server's HTML; nothing replays as the page hydrates.
- The line under the track is kept even while it is empty, on every meter and every
MeterListrow, so the state's words appear without moving what follows.
What you need to do
- Give every meter a
labelthat says what is measured ("Storage", "Seats"), and name eachMeterList; a development build warns about a list with no name. - Write the amount with its unit in
formatValue, so the value text says it ("75.6 GB of 100 GB"), and put what is left, or what to do, innote. - Translate
labels(of,near,over,valueTextandnoValue), or set them once for the app with aLabelsProvider. - Use a meter for a level, not for the progress of a task: assistive tech reads a
meteras a measurement, and a Progress indicator'sprogressbaras work under way. - In forced-colours mode the track keeps a
CanvasTextborder, the fill isCanvasTextand the notch atwarningAtstays a gap, while the state's mark and words carry the warning; keepclassNamesoverrides from removing them.