Data
Stat
A figure worth a glance — what it is, how much, and which way it went — formatted for the locale, with the change read out in words.
WAI-ARIA tested
Import
main.ts
import { Stat } from '@vitral/vue';A row of figures
`delta` is a ratio: `0.125` is +12.5%. The arrow and the colour are not read out, so the change is said in words.
Revenue
$48,250Up 12.4%vs last month
Active users
18KUp 3.1%vs last month
Churn
2.4%0%no change
Orders
When down is good
`invert` for costs, errors and load times: a fall is shown in the good colour, still pointing down.
Median load time
1.18sDown 21%after the image change
Cloud costs
$3,120Up 8%this week
With a sparkline
The `chart` slot sits under the figure.
Visits today
9,512Up 18%
Area chart, 1 series: Visits. Visits, 10 points from 28 to 95. from 1 to 10Left and right arrow keys move between data points, up and down between series, Enter selects.
API
Read from packages/vue/src/components/Stat/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| label | string | — |
| value | number | string | A number is formatted for the locale with `format`; a string is shown as it is. |
| format | Intl.NumberFormatOptions | `Intl.NumberFormat` options for `value`: `{ style: 'currency', currency: 'BRL' }`, `{ notation: 'compact' }`. |
| prefix | string | — |
| suffix | string | — |
| delta | number | string | The change, as a ratio: `0.125` is +12.5%. A string is shown as it is, and then `trend` says which way it went. |
| deltaFormat | Intl.NumberFormatOptions | `Intl.NumberFormat` options for `delta`. Defaults to a signed percentage with one decimal. |
| trend | 'up' | 'down' | 'neutral' | Which way it went; worked out from the sign of a numeric `delta` otherwise. |
| invert | boolean | A fall is the good news: costs, errors, time to load. |
| caption | string | Beside the change: `'vs last month'`. |
| icon | IconProp | — |
| loading | boolean | Keeps the layout and shows a placeholder for the figure. |
| size | Size | — |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Slots
| Name | Slot props | Description |
|---|---|---|
| label | — | — |
| value | (context: { value: string }) | Replaces the formatted figure. |
| icon | — | — |
| caption | — | — |
| chart | — | Below everything: a sparkline, a meter. |