# 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".

## 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, the `low` – `high` band is the warning and above `high` 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.

### More is better

optimum at max flips the bands.

## Playground

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

## Props

| Prop | Type | Default |
| --- | --- | --- |
| `label` | ReactNode (required) | — |
| `hideLabel` | boolean | false |
| `value` | number (required) | — |
| `min` | number | 0 |
| `max` | number (required) | — |
| `low` / `high` | number | — |
| `optimum` | number | `min` |
| `unit` | string | — |
| `locale` | string | the reader's |
| `formatValue` | (value, max) => string | "12,340 / 200,000 tokens" |
| `description` | ReactNode | — |
| `className` / `wrapperClassName` | on 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.
