Skip to main content

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​

Storybook

As Filter Button​

Storybook

Trend Down​

Storybook

Loading​

Storybook

With Meter​

Storybook

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​

VariantWhat it is
staticLabel, value, sub line.
trendArrow and change; good or bad sets the colour plus the arrow direction.
selectableButton that filters the list; is-on ring.
meterInline ProgressBar.
loadingSkeleton 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​

PropTypeDefaultDescription
label *string—Label, shown uppercase. Required
value *ReactNode—The number. Required
subReactNodenoneContext line: what the number counts and over what period
trendstringnoneTrend text, such as "1.4 pts"
trendDir'up' | 'down''up''up' | 'down': arrow before the trend
trendGoodbooleannone (neutral)true colours the trend green, false red
selectedbooleanfalseSelected filter state (with onClick)
onClick(event: MouseEvent<HTMLButtonElement>) => voidnoneMakes the card a toggle button (aria-pressed)
meterStatCardMeternone`{value, max, tone?}` usage meter under the value
loadingbooleanfalseShows 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>
KindNameDescription
attributelabelLabel, shown uppercase. Required
attributetrendTrend text, such as "1.4 pts"; default none
attributetrend-dir / trendDir'up' | 'down': arrow before the trend; default 'up'
attributetrend-good / trendGoodtrue colours the trend green, false red; default none (neutral)
attributeselectedSelected filter state (with onClick); default false
property / JSON attributemeter`{value, max, tone?}` usage meter under the value; default none
attributeloadingShows a skeleton instead of the value; default false
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
attributeauto-focus / autoFocus
eventco-clickMakes the card a toggle button (aria-pressed); default none (React: onClick)
slotvalueThe number. Required Plain text also works as the `value` attribute.
slotsubContext line: what the number counts and over what period; default none Plain text also works as the `sub` attribute.