StatCard
BasicData display
<co-stat-card>StatCard shows one number with its label and context, and can act as a filter button.
import { StatCard } from 'health-components';
Examples
Showcase
As Filter Button
Trend Down
Loading
With Meter
Usage
<StatCard label="Claims to Work" value={42} sub="9 over 30 days" selected={kpi === "work"} onClick={() => setKpi("work")} />
When to use
- Top of dashboards and queues: Claims to Work 42, Denial Rate 6.2%.
When not to use
- Numbers without a comparison or meaning.
Variants and states
| Variant | What it is |
|---|---|
| static | Label, value, sub line. |
| trend | Arrow and change; good or bad sets the colour plus the arrow direction. |
| selectable | Button that filters the list; is-on ring. |
| meter | Inline ProgressBar. |
| loading | Skeleton for the value. |
Accessibility
- Selectable cards are buttons with aria-pressed.
- Trend direction is an arrow character as well as a colour.
- Say what the number counts and over what period in the sub line.
Do and don't
- Do: "Claims to Work 42, 9 over 30 days".
- Don't: A KPI that cannot be traced to a saved report.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | Label, shown uppercase. Required |
value * | ReactNode | — | The number. Required |
sub | ReactNode | none | Context line: what the number counts and over what period |
trend | string | none | Trend text, such as "1.4 pts" |
trendDir | 'up' | 'down' | 'up' | 'up' | 'down': arrow before the trend |
trendGood | boolean | none (neutral) | true colours the trend green, false red |
selected | boolean | false | Selected filter state (with onClick) |
onClick | (event: MouseEvent<HTMLButtonElement>) => void | none | Makes the card a toggle button (aria-pressed) |
meter | StatCardMeter | none | `{value, max, tone?}` usage meter under the value |
loading | boolean | false | Shows a skeleton instead of the value |
Also accepts native attributes, including defaultChecked, defaultValue, autoFocus, plus className and event handlers on the root element.
Angular, Vue and HTML
Register the elements once (Angular guide), then use <co-stat-card>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.
Angular template
<co-stat-card label="…" trend="…" [meter]="meter" (co-click)="onClick($event.detail)"></co-stat-card>
| Kind | Name | Description |
|---|---|---|
| attribute | label | Label, shown uppercase. Required |
| attribute | trend | Trend text, such as "1.4 pts"; default none |
| attribute | trend-dir / trendDir | 'up' | 'down': arrow before the trend; default 'up' |
| attribute | trend-good / trendGood | true colours the trend green, false red; default none (neutral) |
| attribute | selected | Selected filter state (with onClick); default false |
| property / JSON attribute | meter | `{value, max, tone?}` usage meter under the value; default none |
| attribute | loading | Shows a skeleton instead of the value; default false |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus | |
| event | co-click | Makes the card a toggle button (aria-pressed); default none (React: onClick) |
| slot | value | The number. Required Plain text also works as the `value` attribute. |
| slot | sub | Context line: what the number counts and over what period; default none Plain text also works as the `sub` attribute. |