Skip to main content

KPIGrid

ComplexDashboards<co-kpi-grid>

KPIGrid lays out StatCards in a responsive grid and can make them a single-select filter for the table below.

import { KPIGrid } from 'health-components';

Examples​

Filter​

Storybook

Static​

Storybook

Usage​

<KPIGrid filter selected={kpi} onSelect={setKpi} items={[{ label: "Needs Review", value: 14 }, { label: "Pended", value: 6 }]} />

When to use​

  • Top of dashboards and queues.

When not to use​

  • More than 6 numbers: a report.

Variants and states​

VariantWhat it is
staticPlain numbers.
filterSelecting one filters the list; selecting again clears it.

Accessibility​

  • As StatCard: buttons with aria-pressed when filter is on.

Do and don't​

  • Do: Label + count + what it counts.
  • Don't: Mix filter and non-filter cards in one grid.

Props​

PropTypeDefaultDescription
items *KPIGridItem[]—StatCard props[]. Required
filterbooleanfalseCards become a single-select filter (toggle buttons)
selectedstring | nulluncontrolledLabel of the selected card, or null for none (controlled)
defaultSelectedstring | nullnoneInitially selected label (uncontrolled)
onSelect(label: string | null) => voidnone(label | null) => void: selecting the selected card again clears it
labelstringnoneAccessible name of the filter group

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-kpi-grid>. 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-kpi-grid filter selected="…" [items]="items" (co-select)="onSelect($event.detail)"></co-kpi-grid>
KindNameDescription
property / JSON attributeitemsStatCard props[]. Required
attributefilterCards become a single-select filter (toggle buttons); default false
attributeselectedLabel of the selected card, or null for none (controlled); default uncontrolled
attributedefault-selected / defaultSelectedInitially selected label (uncontrolled); default none
attributelabelAccessible name of the filter group; default none
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
attributeauto-focus / autoFocus
eventco-select(label | null) => void: selecting the selected card again clears it; default none (React: onSelect)