- Docs
- Components
- Data display
Stat
A key number with its label, a note and a small trend. Several sit in a StatGroup's ruled strip.
- Import
- @qeetrix/react/experimental
- Status
- ExperimentalSince 0.0.4
- Renders
<dl>Server-rendered- Tested
- WCAG 2.2 AAaxe on every pull request
01
Import
// Experimental: from the package's experimental entry, until it's stable.
import { Stat, StatGroup } from "@qeetrix/react/experimental";02
Props
And every native attribute of the element it renders.
| Prop | Type | Default | What it does |
|---|---|---|---|
label | ReactNode | required | What's counted: "Total users". |
value | ReactNode | required | A number is formatted for locale, as money with currency; pass a string for units and percentages. |
currency | string | — | An ISO code, "INR": money, a whole amount with no fraction. |
format | Intl.NumberFormatOptions | — | Over the defaults, for a numeric value. |
note | ReactNode | — | One line under the value. |
tone | "neutral" | "positive" | "negative" | "warning" | "neutral" | Colours the note. |
trend | number[] | — | Recent values, oldest first, drawn as a small line: decorative. |
chart | ReactNode | — | A small chart under the note, in a summary band: a Meter, a ShareBar. |
action | ReactNode | — | A link at the cell's foot, into the list it counts. |
loading | boolean | false | Placeholders for the value and note; Loading is read instead. |
locale · messages | string · object | the provider's | Formats a numeric value; the Loading string. |
StatGroup: children | Stat[] | — | Side by side in equal ruled cells, at least 200px wide. |
03
Parts
Each part carries a data-slot, for tests and placement.
| data-slot | Element | What it is |
|---|---|---|
stat-group | <dl> | The strip. |
stat | <div> | One stat: aria-busy while loading. |
stat-label | <dt> | The term. |
stat-value | <dd> | The number. |
stat-trend | <svg> | aria-hidden. |
stat-note | <dd> | data-tone. |
04
A figure that isn't money
format: Intl.NumberFormat options for a numeric value, such as a percentage.
<Stat label="Passkey adoption" value={0.72} format={{ style: "percent" }} />