Meter
A horizontal capacity bar with threshold ticks, optional segmentation, and automatic tone escalation — the linear sibling of Gauge.
Import
import { Meter } from "@roger-emerson/ploxum-primitives";Usage
<div className="flex w-64 flex-col gap-3">
<Meter
label="Queue depth — Gate 2"
showValue
thresholds={{ warning: 0.7, critical: 0.9 }}
value={0.78}
/>
<Meter
label="Radio channels in use"
segments={8}
showValue
size="sm"
value={0.625}
/>
</div>Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | — | Percentage 0..1 — values outside the range are clamped. Required. |
label | string | — | Accessible label. Rendered visibly above the track when showValue is set. Required. |
tone | "amber" | "ok" | "warning" | "critical" | "amber" | Base fill tone. Threshold derivation escalates past it when crossed. |
thresholds | MeterThresholds | — | { warning, critical } as 0..1 fractions. Derives the tone and renders tick marks on the track. |
showValue | boolean | — | Show the label and percentage above the track. |
segments | number | — | Divide the track into evenly-spaced segments with tick marks. |
size | "sm" | "md" | "md" | Track height: sm = 4px, md = 6px. |
className | string | — | Merged onto the root. |
ref | Ref<HTMLDivElement> | — | Ref to the root. |
interface MeterThresholds {
/** 0..1 — at or above this the meter renders warning. */
warning: number;
/** 0..1 — at or above this the meter renders critical. */
critical: number;
}The root carries role="meter" with aria-valuenow/aria-valuemin/aria-valuemax.
Design rules
- Threshold ticks are a non-hue signal — they sit on the track at the warning/critical positions in their own tones. Never remove them when thresholds drive the fill color.
- A StatusPip shape marker renders automatically whenever the resolved tone is
warningorcritical(beside the value whenshowValue, beside the track otherwise) — the same shape grammar as Gauge, so status never rides on hue alone. - The width transition (250ms) self-disables at
criticaltone and underprefers-reduced-motion— critical fills snap, motionless per heuristic 3. - Use
segmentsfor discrete capacity (radio channels, dock doors, gate lanes) so operators count units instead of estimating percentages. labelis required even withoutshowValue— the meter is always AT-readable.
