How to build an accessible ContextMeter in React

role="meter" with aria-valuenow/min/max and an aria-valuetext in full words ("12,400 of 200,000 tokens used (6%)"), named by its label. The compact visible line is aria-hidden so it is not read twice. Colour steps to warning at 80% and destructive at 95%, but the figures always carry the meaning

When to use a ContextMeter

When not to use it

Accessibility

Role meter, verified at WCAG 2.2-AA.

Common mistakes

Avoid: Colour alone to signal the window is nearly full

Prefer: Keep the "used / max" figures visible; colour reinforces them

Colour is not perceivable by everyone; the numbers carry the meaning

Example

<ContextMeter value={12400} max={200000} />

See the full ContextMeter reference →