- Docs
- Components
- Feedback
Meter
A measurement within a range: storage used, a quota spent. It looks like Progress; it isn't a task.
- Import
- @qeetrix/react
- Status
- StableSince 0.0.2
- Renders
<div role="meter">Server-rendered- Tested
- WCAG 2.2 AAaxe on every pull request
01
Import
// From the package: a build keeps only what it uses.
import { Meter } from "@qeetrix/react";
// Or from its own path.
import { Meter } from "@qeetrix/react/progress";02
Props
And every native attribute of the element it renders.
| Prop | Type | Default | What it does |
|---|---|---|---|
value | number | required | The measurement, from min to max. |
min · max | number | 0 · 100 | The range. |
target | number | — | A goal on the range: a tick on the track, in the read-out too. It mirrors in right to left. |
label | ReactNode | — | The visible label; without one, an aria-label. |
showValue | boolean | false | The formatted value at the header's end. |
format | Intl.NumberFormatOptions | a percentage | How the value is written and read: { style: "unit", unit: "gigabyte" }. |
tone | "brand" | "neutral" | "info" | "success" | "warning" | "danger" | "brand" | neutral or info for a plain amount; success, warning or danger for how it stands. |
locale · messages | string · object | the provider's | Formats the value; the read-out with a target. |
03
Parts
Each part carries a data-slot, for tests and placement.
| data-slot | Element | What it is |
|---|---|---|
meter | <div role="meter"> | aria-valuenow, aria-valuetext; data-tone. |
meter-header | <div> | The label and the value. |
meter-track | <div> | The track. |
meter-indicator | <div> | The bar. |
meter-target | <span> | target's tick, aria-hidden. |
04
Near a limit
Turn the tone with the value, and put the way out beside it.
const tone = used / limit >= 0.95 ? "danger" : used / limit >= 0.8 ? "warning" : "brand";
<Meter label="SMS credits used" showValue value={used} max={limit} tone={tone} />