Skip to content

Meter

Pro

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

Props

By name or description, across the 29 props below

Meter 16 props

  • labeltype stringRequired

    What the amount is: the meter's name. Untrusted text, rendered as text.

  • valuetype numberRequired

    The amount.

  • maxtype numberRequired

    The limit.

  • iconstype Partial<MeterIcons>

    Replaces the state marks.

  • reftype Ref<HTMLDivElement>

    Ref to the outermost element.

  • idtype string

    The outermost element's id.

  • mintype numberdefault 0

    The least amount.

  • warningAttype number

    From here the meter shows its warning state, with a mark and words.

  • formatValuetype ChartFormatterdefault Intl.NumberFormat in the page's locale

    Formats the amount and the limit.

  • notetype ReactNode

    Under the track: what is left, in the app's words ("24.4 GB left").

Text

  • labelstype Partial<MeterLabels>

    Words it shows and says. A LabelsProvider sets them for the whole app.

  • aria-describedbytype string

    The id of what describes the meter.

  • aria-detailstype string

    The id of what gives more about it.

Also accepts the root element's HTML attributes (id, data-*, event handlers).

MeterList 13 props

  • rowstype readonly MeterListRow[]Required

    The rows, in the app's order.

  • formatValuetype ChartFormatterdefault Intl.NumberFormat in the page's locale

    Formats each amount and limit.

  • iconstype Partial<MeterIcons>

    Replaces the rows' state marks.

  • reftype Ref<HTMLDivElement>

    Ref to the outermost element.

  • idtype string

    The outermost element's id.

Text

  • aria-labeltype string

    Names the list.

  • aria-labelledbytype string

    The id of what names the list.

  • aria-describedbytype string

    The id of what describes the list.

  • aria-detailstype string

    The id of what gives more about it.

  • labelstype Partial<MeterLabels>

    Words it shows and says. A LabelsProvider sets them for the whole app.

Also accepts the root element's HTML attributes (id, data-*, event handlers).

Spec status

Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.

  • Fine, close to the limit and over it (warningAt, max)

    Built

    Configuration · Storage

  • A note under the track (note)

    Built

    Configuration · Storage

  • Several amounts, each against its own limit (MeterList)

    Built

    Variant · Limits

  • A list in a narrow container, each track under its name

    Built

    Configuration · Limits

  • A new amount

    Built

    Use case · Changing

  • Not an M3 component

    Extension

    M3 has no meter or chart components; this is a role="meter" from React Aria, drawn in M3’s colour roles, shapes and springs, with the theme’s warning and error roles for its states.

  • States in words

    Extension

    Near the limit and past it, the meter shows a mark and words and says them in its value text, never colour alone.

Theming & tokens

Set the tokens below on the meter, the list or any ancestor; a MeterList reads the same set, with three tokens of its own (column-gap, list-figure-gap and name-width). The fill and the marks take the shared chart tokens: --wm-chart-color-1 while fine, --wm-chart-warning and --wm-chart-critical past warningAt and max. The track and the notch are drawn from --wm-chart-surface: on a card of another colour than surface, set it to the card's. className goes on the root; style a meter's parts with classNames: label, meter, figure, value, limit, track, fill, notch, note, status, statusIcon. A MeterList's classNames take each row's parts too, with list, row, name in place of label.

Meter tokens
VariableDefaultPaints
--wm-meter-gap8pxThe space between the figure, the track and the note.
--wm-meter-figure-gap8pxThe space between the amount and the limit beside it.
--wm-meter-note-gap8pxThe space between the state’s words and the note after them.
--wm-meter-status-gap4pxThe space between the state’s mark and its words.
--wm-meter-column-gap16pxIn a MeterList, the space between the names, the tracks and the figures.
--wm-meter-list-figure-gap4pxIn a MeterList, the space between a row’s amount and its limit.
--wm-meter-track-height8pxThe track’s height.
--wm-meter-track-shapevar(--md-sys-shape-corner-full)The track’s and the fill’s corners.
--wm-meter-track-colorcolor-mix(in srgb, var(--md-sys-color-on-surface) 12%, var(--_wm-chart-surface))What is left: the track behind the fill, a step off the surface it is drawn on (a frame’s card too).
--wm-meter-notch-width2pxThe gap of the chart’s surface that marks `warningAt` on the track.
--wm-meter-label-colorvar(--md-sys-color-on-surface-variant)What the amount is.
--wm-meter-value-colorvar(--md-sys-color-on-surface)The amount.
--wm-meter-limit-colorvar(--md-sys-color-on-surface-variant)The limit beside the amount.
--wm-meter-note-colorvar(--md-sys-color-on-surface-variant)The note under the track (what is left), and the status words.
--wm-meter-status-icon-size18pxThe mark beside the status words near or over the limit.
--wm-meter-fill-durationvar(--md-sys-motion-spring-spatial-default-duration)How long the fill takes to grow or shrink to a new amount.
--wm-meter-fill-easingvar(--md-sys-motion-spring-spatial-default-easing)The easing of that change.
--wm-meter-name-width12remIn a MeterList, the most the names’ column takes before the tracks.