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
Static
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
| Variant | What it is |
|---|---|
| static | Plain numbers. |
| filter | Selecting 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
| Prop | Type | Default | Description |
|---|---|---|---|
items * | KPIGridItem[] | — | StatCard props[]. Required |
filter | boolean | false | Cards become a single-select filter (toggle buttons) |
selected | string | null | uncontrolled | Label of the selected card, or null for none (controlled) |
defaultSelected | string | null | none | Initially selected label (uncontrolled) |
onSelect | (label: string | null) => void | none | (label | null) => void: selecting the selected card again clears it |
label | string | none | Accessible 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>
| Kind | Name | Description |
|---|---|---|
| property / JSON attribute | items | StatCard props[]. Required |
| attribute | filter | Cards become a single-select filter (toggle buttons); default false |
| attribute | selected | Label of the selected card, or null for none (controlled); default uncontrolled |
| attribute | default-selected / defaultSelected | Initially selected label (uncontrolled); default none |
| attribute | label | Accessible name of the filter group; default none |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus | |
| event | co-select | (label | null) => void: selecting the selected card again clears it; default none (React: onSelect) |