Usage against a limit
import { Meter } from "@senvenli/react/feedback";
export default function Example() {
return <Meter label="Seats" value={18} maxValue={50} />;
}import { Meter } from "@senvenli/react/feedback";Examples
Warning and critical
Past a threshold the segments and the value text change color; the value label says it in words too.import { Meter } from "@senvenli/react/feedback";
import { Stack } from "@senvenli/react/layout";
const THRESHOLDS = { warning: 40, critical: 48 };
export default function Example() {
return (
<Stack space="space-300">
<Meter label="Storage" value={22} maxValue={50} thresholds={THRESHOLDS} valueLabel="22 / 50 GB" />
<Meter label="Storage" value={43} maxValue={50} thresholds={THRESHOLDS} valueLabel="43 / 50 GB · almost full" />
<Meter label="Storage" value={49} maxValue={50} thresholds={THRESHOLDS} valueLabel="49 / 50 GB · full soon" />
</Stack>
);
}When low is bad
`badEnd="low"` warns as the value runs out.import { Meter } from "@senvenli/react/feedback";
export default function Example() {
return (
<Meter
label="Email credits"
value={150}
maxValue={1200}
segments={12}
badEnd="low"
thresholds={{ warning: 300, critical: 100 }}
valueLabel="150 of 1,200 left · top up soon"
/>
);
}Guidelines
When to use it
- Showing how much of a limit is used: storage, seats, quota.
Use something else when
- The value is a task's progress. Progress
- One headline value on a dashboard reads better as a half ring with a target. Gauge chart
Accessibility
Built in
- Exposed as a meter with its value text.
You provide
- A
labeland a value label in real units.
API reference
Meter
| Prop | Type | Default | Description |
|---|---|---|---|
labelRequired | React.ReactNode | – | |
valueRequired | number | – | |
maxValueRequired | number | – | |
badEnd | "high" | "low" | "high" | Which end is the bad one: |
segments | number | 10 | Segments in the track: 10, or the real unit count (8 for fuel eighths). |
thresholds | MeterThresholds | – | |
valueLabel | string | – | "38 / 50", "460 / 500 · 92%", "1/8 · refill soon": the state in words too, never colour alone. Defaults to "value / max". |
labelRequiredReact.ReactNodevalueRequirednumbermaxValueRequirednumberbadEnd"high" | "low"Default"high"Which end is the bad one:
high(quota, usage; default) warns as the value grows,low(fuel, credit left) warns as it shrinks.segmentsnumberDefault10Segments in the track: 10, or the real unit count (8 for fuel eighths).
thresholdsMeterThresholdsvalueLabelstring"38 / 50", "460 / 500 · 92%", "1/8 · refill soon": the state in words too, never colour alone. Defaults to "value / max".