Docs menu

Guides


Primitives
Forms
Layout
Feedback
Overlays
Navigation
Data Display
AI

Usage Meter

Token, credit or quota usage on a real <meter>, the HTML element for "a measurement within a known range". Not a<progress>: usage isn't a task heading for completion, and <meter>'s low,high and optimum attributes already say "this much is fine, this much is a warning".

Resets on the 1st.

Bands

The colour follows the same region algorithm the browser uses for<meter>, so it always agrees with what assistive tech is told. optimum defaults to min, because for usage less is better: above high the bar turns to warning, and with low set too, thelow–high band is the warning and abovehigh is danger. A full meter is always danger.usageMeterLevel() is exported if you need the same answer elsewhere.

The native bar is restyled with ::-webkit-meter-* and::-moz-meter-bar, since there's no standard, unprefixed way yet, reading tokens only.

Examples

Warning

Above high, with optimum at the default min.

Usage
<UsageMeter
  label="Context window"
  value={172_000}
  max={200_000}
  high={160_000}
  unit="tokens"
/>

More is better

optimum at max flips the bands.

Usage
<UsageMeter
  label="Battery"
  value={82}
  max={100}
  low={20}
  high={50}
  optimum={100}
  formatValue={(value) => `${value}%`}
/>

Playground

Toggle every adjustable prop and watch the component — and the code — update live.

Unstyled

Same component — Kernel look stripped. See Platforms.

hideLabel
Usage
<UsageMeter
  label="Context window"
  value={128000}
  max={200000}
  high={160000}
  unit="tokens"
/>

Props

Props for Usage Meter.
PropTypeDefault
labelReactNode (required)—
hideLabelbooleanfalse
valuenumber (required)—
minnumber0
maxnumber (required)—
low / highnumber—
optimumnumbermin
unitstring—
localestringthe reader's
formatValue(value, max) => string"12,340 / 200,000 tokens"
descriptionReactNode—
className / wrapperClassNameon the meter / the wrapper—

Accessibility

  • The label is a real <label for>: <meter> is a labelable element.
  • The formatted text is the meter's aria-valuetext, so it's read with its unit; the visible copy is aria-hidden so it isn't read twice.
  • Colour is never the only signal: the value text is always shown.