Stat
A KPI tile with a label, a preformatted value, an optional delta and caption, laid out in rows with StatGroup.
Overview
Stat shows one number with its label and, optionally, how it changed. The value is rendered as given: format numbers, money and units before passing them. The delta colour follows sentiment, so a value that goes up can still read as bad (e.g. spend). StatGroup lays several tiles out in a responsive row.
By default the tile sits in a Card; set bare to render it without one.
Import
import { Stat, StatGroup } from '@unflowio/ui/components/Stat';Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | — | Required. What the number measures |
value | ReactNode | — | Required. The value, already formatted |
suffix | ReactNode | — | Text after the value, in a smaller size (e.g. "of 86") |
delta | StatDelta | — | Change against a reference period |
caption | ReactNode | — | Context for the delta, or a standalone note (e.g. "vs September") |
icon | ReactNode | — | Decorative icon before the label |
loading | boolean | — | Shows skeletons instead of the value and delta |
trend | ReactNode | — | A small chart (e.g. a sparkline) under the value |
bare | boolean | — | Renders without the surrounding Card |
variant | 'muted' | 'raised' | 'muted' | Variant of the surrounding Card |
StatDelta:
| Field | Type | Description |
|---|---|---|
value | string | Required. Formatted change (e.g. "+9%", "€282.55") |
direction | 'up' | 'down' | 'flat' | Required. Drives the arrow |
sentiment | 'positive' | 'negative' | 'neutral' | Drives the colour. Defaults to positive for up, negative for down and neutral for flat |
StatGroup takes standard div props and lays its children out in a grid.
Basic usage
Active people
74of 86
Increase +9%vs September
<Stat
label="Active people"
value="74"
suffix="of 86"
delta={{ value: '+9%', direction: 'up' }}
caption="vs September"
/>Sentiment
Override sentiment when the direction alone gives the wrong colour.
Runs
9,412
Increase +12%vs September
Spend
€2,184.60
Increase +€282vs September
Failed runs
12
Decrease -40%vs September
Workspaces
4
No change 0vs September
<StatGroup>
<Stat label="Runs" value="9,412" delta={{ value: '+12%', direction: 'up' }} />
<Stat label="Spend" value="€2,184.60" delta={{ value: '+€282', direction: 'up', sentiment: 'negative' }} />
<Stat label="Failed runs" value="12" delta={{ value: '-40%', direction: 'down', sentiment: 'positive' }} />
<Stat label="Workspaces" value="4" delta={{ value: '0', direction: 'flat' }} />
</StatGroup>Loading and bare
Runs
Runs
9,412
Month to date
<Stat label="Runs" value="9,412" delta={{ value: '+12%', direction: 'up' }} loading />
<Stat label="Runs" value="9,412" caption="Month to date" bare />Customization (slotProps)
| Slot Prop | Props | Description |
|---|---|---|
label | BaseHTMLProps<HTMLParagraphElement> | The label |
value | BaseHTMLProps<HTMLParagraphElement> | The value row |
delta | BaseHTMLProps<HTMLParagraphElement> | The delta row |
card | Partial<ICard> | Props for the surrounding Card |
Accessibility
- The delta direction is also announced as visually hidden text, so it doesn't rely on the arrow or the colour.
- While
loading, the tile setsaria-busyand the skeletons are hidden from assistive technology.