KpiGrid
The v3 mock's .kpis: four (or columns={3}) across, two below 1100px, one below 600px (or two down to 360px, phoneColumns={2}). columns={2} draws a two-card strip down to 600px.
import { KpiGrid } from '@ergasti/bricks';Examples
Filter cards
A clickable card toggles a filter (active); progress draws a bar; deco adds the corner shape.
Code
import { useState } from 'react';
import { KpiCard, KpiGrid } from '@ergasti/bricks';
function Filters() {
const [chip, setChip] = useState<'all' | 'active' | 'paused'>('all');
return (
<KpiGrid>
<KpiCard tone="lime" icon="user" label="Active" value="301" sub="In your program now" active={chip === 'active'} onClick={() => setChip(chip === 'active' ? 'all' : 'active')} deco="blob" />
<KpiCard tone="butter" icon="pause" label="Paused" value="3" sub="Coupons stopped for now" active={chip === 'paused'} onClick={() => setChip(chip === 'paused' ? 'all' : 'paused')} />
<KpiCard tone="sky" icon="creators" label="Groups" value="3" sub="Open the Groups tab" onClick={() => {}} deco="star" />
<KpiCard tone="lilac" icon="seat" label="Seats left" value="79" sub="321 of 400 seats used" progress={80} onClick={() => {}} />
</KpiGrid>
);
}Read-only
Without onClick the card is plain text, not a button.
Code
import { KpiCard, KpiGrid } from '@ergasti/bricks';
function ReadOnly() {
return (
<KpiGrid>
<KpiCard tone="rasp" icon="payments" label="Paid" value="EGP 275K" sub="This month" />
<KpiCard tone="sky" icon="log" label="Pending" value="EGP 96K" sub="Waiting for approval" />
</KpiGrid>
);
}Two across on a phone
A KpiGrid is four across, two below 1100px and one below 600px; phoneColumns={2} keeps two cards across down to 360px, for short cards. Narrow the window under 600px to see it.
Code
import { KpiCard, KpiGrid } from '@ergasti/bricks';
function PhoneColumns() {
return (
<KpiGrid phoneColumns={2}>
<KpiCard tone="lime" icon="user" label="Active" value="301" />
<KpiCard tone="butter" icon="pause" label="Paused" value="3" />
<KpiCard tone="sky" icon="creators" label="Groups" value="3" />
<KpiCard tone="lilac" icon="seat" label="Seats left" value="79" />
</KpiGrid>
);
}Short cards
For a strip above a list (the PR Creators page), give the grid size="short": every card in it loses its minimum height and gets 12 16 padding and a 22px value. KpiCard size="short" is the same card on its own, for one outside such a grid (here, beside a heading). Keep the defaults for a dashboard's main figures.
Code
import { KpiCard, KpiGrid, PrIcon } from '@ergasti/bricks';
function Short() {
return (
<div style={{ display: 'grid', gap: 16 }}>
<KpiGrid size="short">
<KpiCard tone="lime" icon="user" label="Active" value="10" sub="Approved and selling" />
<KpiCard tone="butter" icon="log" label="Pending" value="2" sub="Waiting for PR approval" />
<KpiCard tone="sky" icon={<PrIcon name="tiers" />} label="Elite" value="4" sub="Top tier" />
<KpiCard tone="lilac" icon="creators" label="Customers" value="38" sub="Customer affiliates" />
</KpiGrid>
<div style={{ maxWidth: 240 }}>
<KpiCard size="short" tone="rasp" icon="clock" label="Waiting for you" value="3" sub="Join requests" />
</div>
</div>
);
}Any icon
icon takes a kit icon name or any element, such as a <PrIcon> or your own svg; it is drawn 15px in the card's ink and hidden from screen readers.
Code
import { KpiCard, KpiGrid, PrIcon } from '@ergasti/bricks';
function ElementIcon() {
return (
<KpiGrid>
<KpiCard tone="sky" icon={<PrIcon name="tiers" />} label="Elite" value="4" sub="Top tier" />
<KpiCard tone="lilac" icon={<svg viewBox="0 0 24 24"><path d="M5 12h14M12 5v14" /></svg>} label="New this week" value="12" sub="Joined since Monday" />
</KpiGrid>
);
}Three across
columns={3} draws the PR Messages strip: three cards across at every width down to 600px (a four-card grid drops to two below 1100px), then one per row on a phone. columns={2} does the same with two.
Code
import { KpiCard, KpiGrid } from '@ergasti/bricks';
function Columns() {
return (
<KpiGrid columns={3}>
<KpiCard tone="rasp" icon="mail" label="Messages sent" value="7" sub="Last 30 days" />
<KpiCard tone="lime" icon="eye" label="Opened on average" value="81%" sub="Of creators who got one" progress={81} />
<KpiCard tone="sky" icon="creators" label="Creators reached" value="2,153" sub="Across all messages" />
</KpiGrid>
);
}Two across
columns={2} keeps two cards side by side at every width down to 600px (a pair of wallet figures); under 600px phoneColumns applies.
Code
import { KpiCard, KpiGrid, Money } from '@ergasti/bricks';
function TwoAcross() {
return (
<KpiGrid columns={2}>
<KpiCard tone="lime" icon="wallet" label="To be paid this month" value={<Money value="48200.00" />} sub="34 creators" />
<KpiCard tone="sky" icon="check" label="Paid so far" value={<Money value="112900.00" />} sub="Since 1 Nov" />
</KpiGrid>
);
}Props
Prop
Type
Accessibility
- ARIA attributes set:
aria-pressed,aria-labelledby,aria-hidden. - Its tests cover: “icon chip + label, value, sub and an optional progress bar (clamped 2–100)”; “a filter card has one button (laid over it) with aria-pressed, named by label and value; click, Enter and Space toggle it”; “Arabic + RTL: the label in Arabic, the value isolated LTR; the grid wraps the cards”.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
Deco · Icon · Filters · KpiCard · PrIcon · Money · Accordion · Card · HeroCard · KeyValue
Source
src/kit/patterns/KpiCard.tsx (line 83) on GitHub.