Components
Stat
Inline label and value with an optional toned delta and note, laid out in a wrapping group.
import { Stat } from "@openperf/deft";
<Stat.Group>
<Stat.Root>
<Stat.Label>Duration</Stat.Label>
<Stat.Value>128 ms</Stat.Value>
</Stat.Root>
</Stat.Group>;When to use
| Need | Component |
|---|---|
| A few short values side by side in the flow of a page | Stat |
| Headline number in a card, with a comparison or a chart | Metric |
| Number put in proportion by a bar | Meter |
| Text attributes with long values | Key value |
Anatomy
<Stat.Group>
{/* one label and one value on a shared baseline */}
<Stat.Root>
<Stat.Label />
<Stat.Value>
{value}
<Stat.Delta /> {/* after the number */}
<Stat.Note />
</Stat.Value>
</Stat.Root>
</Stat.Group>Stat.Group is a description list that wraps onto more lines, so keep every Stat.Root inside one. Stat formats nothing: pass the value, the unit and the sign of the change as ready text.
Deltas
Stat does not know whether a rise is good or bad: choose success, warning or danger yourself, or keep neutral for a change with no judgment. Stat.Delta also works on its own, for example in the change column of a table.
Notes
Stat.Note adds muted text after the value for context that is not a change.
API
Stat.Delta
Prop
Type