nook
Browse the docs

Components

Stat card

Native

A labelled metric, change in words and optional sparkline with its data table.

See the prompt

Monthly recurring revenue

$28,460

Increased by 12.8% vs October

142 active Studio subscriptions

Monthly recurring revenue trend
ObservationValue
118
222
320
425
523
628
727
831
934
1032
1138
1242

Installation

npx nook-ui@latest add stat-card

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 "Stat card" component to this project, exactly as Nook ships it.

A labelled metric, change in words and optional sparkline with its data table.

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 stat-card`. It writes `components/ui/stat-card.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/stat-card.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 { StatCard } from "@/components/ui/stat-card";
export default function Example() {
  return (
    <StatCard
      className="w-full max-w-sm"
      label="Monthly recurring revenue"
      value="$28,460"
      change={12.8}
      comparison="vs October"
      description="142 active Studio subscriptions"
      trend={[18, 22, 20, 25, 23, 28, 27, 31, 34, 32, 38, 42]}
    />
  );
}
```

API
- `StatCard`: A labelled metric, change in words and optional sparkline with its data table.
  - `label / value` (`string / ReactNode`): Metric name and formatted value.
  - `change` (`number`): Signed percentage change.
  - `comparison` (`string`, default vs previous period): Comparison period.
  - `trend` (`number[]`): Observations for the optional Sparkline.
  - `description` (`string`): Supporting context.

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: Changes are written as increased, decreased or unchanged; the sparkline has a complete data alternative.

Done when the component renders like the example in light and dark mode and the project type-checks.

Usage

import { StatCard } from "@/components/ui/stat-card";
export default function Example() {
  return (
    <StatCard
      className="w-full max-w-sm"
      label="Monthly recurring revenue"
      value="$28,460"
      change={12.8}
      comparison="vs October"
      description="142 active Studio subscriptions"
      trend={[18, 22, 20, 25, 23, 28, 27, 31, 34, 32, 38, 42]}
    />
  );
}

Examples

Without a chart

Open tickets

38

6 assigned to you

Avg. first reply

2h 14m

Decreased by 9.4% vs last week

Going down

Churned customers

23

Decreased by 18.2% vs October

Churned customers trend
ObservationValue
140
238
335
436
530
628
726
824
923

Dashboard row

Visitors

48,210

Increased by 6.1% vs last month

Visitors trend
ObservationValue
130
232
331
436
540
644
748

Sign-ups

1,204

Increased by 14.3% vs last month

Sign-ups trend
ObservationValue
110
212
311
415
518
619
722

Conversion

2.5%

Unchanged no change

With trends

Weekly sign-ups

1,284

Increased by 12.4% vs last week

Weekly sign-ups trend
ObservationValue
1820
2910
3880
41010
51100
61190
71284

Churned accounts

37

Decreased by 18% vs last week

Lower is better

Churned accounts trend
ObservationValue
152
249
347
444
541
640
737

Plain stats

Open invoices

14

Unpaid total

$8,420

Across 6 customers

Average days to pay

19

Unchanged no change

Props

StatCard

A labelled metric, change in words and optional sparkline with its data table.

PropTypeDefaultDescription
label / valuestring / ReactNode–Metric name and formatted value.
changenumber–Signed percentage change.
comparisonstringvs previous periodComparison period.
trendnumber[]–Observations for the optional Sparkline.
descriptionstring–Supporting context.

Accessibility

Changes are written as increased, decreased or unchanged; the sparkline has a complete data alternative.

Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.