nook
Browse the docs

Components

KPI grid

Native

Responsive stat cards that share one reporting-period switch.

See the prompt

Workspace overview

Showing This week

Revenue

$7,240

Increased by 8.2% vs previous period

Revenue trend
ObservationValue
13
24
33
46
55
67

New customers

38

Increased by 12% vs previous period

New customers trend
ObservationValue
12
23
34
43
56
68

Open requests

12

Decreased by 25% vs previous period

Median reply time: 18 minutes

Installation

npx nook-ui@latest add kpi-grid

Prompt

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.

Plain text
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

Tickets trend
ObservationValue
1180
2220
3210
4190
5170
6160
7154

First reply

42 min

Decreased by 18% vs previous 30 days

First reply trend
ObservationValue
180
274
366
460
555
648
742

Props

KpiGrid

Responsive stat cards that share one reporting-period switch.

PropTypeDefaultDescription
periodsKpiPeriod[]–Period IDs, labels and metric cards.
value / defaultValuestring–Selected period ID.
onValueChange(period: string) => void–Receives reporting period changes.
titlestringWorkspace overviewSection 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.