Components
Meter
Static proportion bars for a share, a period comparison, a breakdown, a percentile range, a threshold scale and a distribution.
import { Meter } from "@openperf/deft";
<Meter.Root value={0.48} />;When to use
| Need | Component |
|---|---|
| A number in proportion, inside a table cell or a card | Meter |
| Values over time with axes and a tooltip | Chart |
| Compact trend shape without axes | Sparkline |
| The number itself — a meter does not replace it | Stat or Metric |
Each part is a standalone meter, not a piece of one composition.
Share
value is a fraction: 0.48 reads as 48%, formatted for the active locale. Meter.Root is 88px wide, label included.
max changes only the length of the bar, not the label. In a table column, pass the largest share as max so that row fills the track and the others are drawn relative to it:
<Meter.Root className="w-full" max={largestShare} value={row.share} />Compare
The longer bar fills the track and the other is drawn relative to it. value sets the length of a bar and text is the formatted value printed at the right, so the two can differ in unit and precision. tone colors the current bar only.
Parts
Parts keep the order you pass, so sort them first. With more than seven parts, the first six are shown and the rest are summed into a translated "Other" part. Hovering a segment or its legend row highlights the pair.
With legend={false}, color your own swatches with the exported partsRampClassNames: seven background classes in segment order.
Range
A thick bar runs from p50 to p95, a thin tail from p95 to p99, and a marker sits at p95. The scale is logarithmic and 168px wide. Values outside domain are clamped; use one domain for every row of a table so the rows compare.
Scale
Three zones of equal width, whatever the thresholds are.
value | Marker lands in |
|---|---|
Up to good | First third |
good to poor | Middle third |
Above poor | Last third; reaches the end at 1.5 × poor |
| Not set | No marker |
Distribution
Only the ratio of the three numbers matters, so pass counts or percents. A segment with a value of zero is not drawn.
API
The meters set no ARIA role or value. Meter.Range, Meter.Scale, Meter.Distribution and Meter.Root with showValue={false} render no text: show the numbers next to them, or pass title or aria-label.
Meter.Root and Meter.Parts format numbers for the active locale and need the Lingui provider.
Meter.Root
Prop
Type
Meter.Compare
Prop
Type
Meter.Parts
Prop
Type
Meter.Range
Prop
Type
Meter.Scale
Prop
Type
Meter.Distribution
Prop
Type