Components
KPI grid
NativeResponsive stat cards that share one reporting-period switch.
Workspace overview
Showing This week
Revenue
$7,240
Increased by 8.2% vs previous period
| Observation | Value |
|---|---|
| 1 | 3 |
| 2 | 4 |
| 3 | 3 |
| 4 | 6 |
| 5 | 5 |
| 6 | 7 |
New customers
38
Increased by 12% vs previous period
| Observation | Value |
|---|---|
| 1 | 2 |
| 2 | 3 |
| 3 | 4 |
| 4 | 3 |
| 5 | 6 |
| 6 | 8 |
Open requests
12
Decreased by 25% vs previous period
Median reply time: 18 minutes
Installation
npx nook-ui@latest add kpi-gridPrompt
Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.
Short. For assistants that can run commands in your project.
Add the Nook "KPI grid" component to this project, exactly as Nook ships it.
Responsive stat cards that share one reporting-period switch.
Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add kpi-grid`. It writes `components/ui/kpi-grid.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/kpi-grid.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:
```tsx
import { KpiGrid } from "@/components/ui/kpi-grid";
export default function Example() {
return (
<KpiGrid
className="w-full"
periods={[
{
value: "week",
label: "This week",
metrics: [
{
id: "revenue",
label: "Revenue",
value: "$7,240",
change: 8.2,
trend: [3, 4, 3, 6, 5, 7],
},
{
id: "customers",
label: "New customers",
value: "38",
change: 12,
trend: [2, 3, 4, 3, 6, 8],
},
{
id: "support",
label: "Open requests",
value: "12",
change: -25,
description: "Median reply time: 18 minutes",
},
],
},
{
value: "month",
label: "This month",
metrics: [
{
id: "revenue",
label: "Revenue",
value: "$28,460",
change: 12.8,
trend: [18, 22, 20, 25, 28, 32],
},
{
id: "customers",
label: "New customers",
value: "142",
change: 18,
trend: [8, 12, 11, 17, 20, 24],
},
{
id: "support",
label: "Open requests",
value: "12",
change: -14.3,
description: "Median reply time: 22 minutes",
},
],
},
]}
/>
);
}
```
API
- `KpiGrid`: Responsive stat cards that share one reporting-period switch.
- `periods` (`KpiPeriod[]`): Period IDs, labels and metric cards.
- `value / defaultValue` (`string`): Selected period ID.
- `onValueChange` (`(period: string) => void`): Receives reporting period changes.
- `title` (`string`, default Workspace overview): Section heading.
Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Uses ToggleGroup keyboard behavior; selected period is announced and every metric has written change.
Done when the component renders like the example in light and dark mode and the project type-checks.Usage
import { KpiGrid } from "@/components/ui/kpi-grid";
export default function Example() {
return (
<KpiGrid
className="w-full"
periods={[
{
value: "week",
label: "This week",
metrics: [
{
id: "revenue",
label: "Revenue",
value: "$7,240",
change: 8.2,
trend: [3, 4, 3, 6, 5, 7],
},
{
id: "customers",
label: "New customers",
value: "38",
change: 12,
trend: [2, 3, 4, 3, 6, 8],
},
{
id: "support",
label: "Open requests",
value: "12",
change: -25,
description: "Median reply time: 18 minutes",
},
],
},
{
value: "month",
label: "This month",
metrics: [
{
id: "revenue",
label: "Revenue",
value: "$28,460",
change: 12.8,
trend: [18, 22, 20, 25, 28, 32],
},
{
id: "customers",
label: "New customers",
value: "142",
change: 18,
trend: [8, 12, 11, 17, 20, 24],
},
{
id: "support",
label: "Open requests",
value: "12",
change: -14.3,
description: "Median reply time: 22 minutes",
},
],
},
]}
/>
);
}Examples
Week and month
Shop overview
Showing This week
Revenue
$12,480
Increased by 6.2% vs last week
Orders
214
Decreased by 2.1% vs last week
Average order
$58.32
Increased by 8.4% vs last week
With trends
Support
Showing Last 30 days
Tickets
1,284
Decreased by 9.3% vs previous 30 days
Fewer is better
| Observation | Value |
|---|---|
| 1 | 180 |
| 2 | 220 |
| 3 | 210 |
| 4 | 190 |
| 5 | 170 |
| 6 | 160 |
| 7 | 154 |
First reply
42 min
Decreased by 18% vs previous 30 days
| Observation | Value |
|---|---|
| 1 | 80 |
| 2 | 74 |
| 3 | 66 |
| 4 | 60 |
| 5 | 55 |
| 6 | 48 |
| 7 | 42 |
Props
KpiGrid
Responsive stat cards that share one reporting-period switch.
| Prop | Type | Default | Description |
|---|---|---|---|
| periods | KpiPeriod[] | – | Period IDs, labels and metric cards. |
| value / defaultValue | string | – | Selected period ID. |
| onValueChange | (period: string) => void | – | Receives reporting period changes. |
| title | string | Workspace overview | Section heading. |
Accessibility
Uses ToggleGroup keyboard behavior; selected period is announced and every metric has written change.
Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.