StatGrid
A row of KpiCards at a set count (the Gifts tab draws five across; KpiGrid is four). Below 1100px it wraps to as many 160px cards as fit, below 600px one per row.
import { StatGrid } from '@ergasti/bricks';Examples
Stat grid
A row of KPI cards in columns equal columns; it drops to fewer columns on narrow screens.
Code
import { KpiCard, StatGrid } from '@ergasti/bricks';
function Gifts() {
return (
<StatGrid columns={3}>
<KpiCard tone="lime" icon="gift" label="In stock" value={32} sub="Gifts left to pick" />
<KpiCard tone="lilac" icon="user" label="Picked" value={83} sub="By creators" />
<KpiCard tone="rasp" icon="gift" label="Delivered" value={63} sub="Reached the creator" onClick={() => {}} active={false} />
</StatGrid>
);
}Props
Prop
Type
Design guidance
How the BRICKS design system uses StatGrid. Written in docs/content/components/StatGrid.md; the props above are read from the code, which wins where the two disagree.
A grid of KPI cards at a set column count (five across for the Gifts tab), folding to as many 160px cards as fit below 1100px and one per row below 600px; use it when KpiGrid's fixed four columns do not fit the row.
It is the Motivation › Gifts tab's five stat cards (the mock's gifts .kpis, 5 across): In stock, Picked, Shipped, Not delivered yet, Delivered. The last three are clickable filters for the orders table below. StatGrid is layout only; the cards are KpiCards.
Anatomy
- Grid (
.kit-blk-stats):repeat(var(--blk-cols), minmax(0, 1fr)), gap 14, 16px below. - Children:
KpiCards (tone chip, label, value, sub; optionallyactive+onClick).
Variants
columns | Look | Use when |
|---|---|---|
5 | Five across | Gifts tab stats (the mock). |
3 | Three across | Smaller stat groups (story ThreeColumns). |
| any number | That many columns at ≥1100px | Match the count of cards. |
Responsive: ≤1100px repeat(auto-fit, minmax(160px, 1fr)); ≤600px one column.
States
Layout has none; the cards carry active (selected filter) and hover/focus when clickable.
Usage
// Motivation › Gifts: five stats, three of them filter the orders table
<StatGrid columns={5}>
<KpiCard tone="lime" icon="gift" label="In stock" value={32} sub="Units left to pick" />
<KpiCard tone="lilac" icon="user" label="Picked" value={83} sub="By creators so far" />
<KpiCard tone="sky" icon="payments" label="Shipped" value={10} sub="On the way" active={chip === 'shipped'} onClick={() => toggle('shipped')} />
<KpiCard tone="butter" icon="flag" label="Not delivered yet" value={20} sub="Waiting or on the way" active={chip === 'pending'} onClick={() => toggle('pending')} />
<KpiCard tone="rasp" icon="gift" label="Delivered" value={63} sub="Arrived" active={chip === 'delivered'} onClick={() => toggle('delivered')} />
</StatGrid>
<Card>
<DataTable label="Gift orders" rows={filtered} columns={columns} rowKey={(o) => o.id} />
</Card>Where it appears
- Brand › Motivation › Gifts tab › the five stat cards above the gift orders table. Screen: Motivation · Gifts.
Guidelines
Do
- Set
columnsto the number of cards. - Give each card a different tone, in the mock's order.
- Mark the clickable cards' current filter with
active.
Don't
- Don't use it for exactly four KPIs:
KpiGridis the standard row. - Don't mix card types (Tile and KpiCard) in one grid.
RTL and Arabic
- Columns flow right to left; Arabic labels ("في المخزن", "اتاخد", "اتشحن", "لسه متسلمش", "اتسلّم") may wrap to two lines inside the cards.
Tokens
--blk-cols (set inline from columns); card tokens from KpiCard. Inside the shell main area its bottom margin is removed (the shell's gap applies).
Accessibility
- A plain
<div>grid; semantics come from the cards (KpiCardwithonClickis a toggle button witharia-pressed). - Reading order follows source order at every breakpoint.
Found in the source
- No roles, ARIA attributes or key handling are set in this component's own source; it renders native elements and the components it composes.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
KpiGrid: the four-across KPI row.KpiCard/Tile: the cards.QueueTile(PR): the approvals queue's count tiles.
See also: CalloutCard · CheckList · CopyLinkField · DrawerHead
Source
src/blocks/shared/StatGrid.tsx (line 8) on GitHub.