Components
Heatmap
NativeA calendar of square cells, one per day, darker where there was more.
Installation
npx nook-ui@latest add heatmapPrompt
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 "Heatmap" component to this project, exactly as Nook ships it.
A calendar of square cells, one per day, darker where there was more.
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 heatmap`. It writes `components/ui/heatmap.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/heatmap.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 { Heatmap } from "@/components/ui/heatmap";
// Made-up activity for 2026: quiet weekends, busier towards the end of each month.
const DATA = Array.from({ length: 365 }, (_, index) => {
const date = new Date(Date.UTC(2026, 0, 1 + index));
const weekend = date.getUTCDay() === 0 || date.getUTCDay() === 6;
const wave = (Math.sin(index / 9) + 1) * 2 + (index * 7) % 5;
const value = weekend ? ((index * 3) % 4 === 0 ? 1 : 0) : Math.max(0, Math.round(wave) - ((index * 11) % 3 === 0 ? 4 : 0));
return { date: date.toISOString().slice(0, 10), value };
});
export default function HeatmapDefault() {
return <Heatmap className="w-full" title="Your progress timeline for 2026" data={DATA} formatDay={(date, value) => `${date.toISOString().slice(0, 10)}: ${value} lessons`} />;
}
```
API
- `Heatmap`: The calendar.
- `data` (`{ date, value }[]`): One entry per day, with ISO dates.
- `title` (`string`): What the map shows.
- `formatDay` (`(date: Date, value: number) => string`): Text of the hover label.
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: Renders a single image whose name is the title plus the number of active days. Pair it with a list or table when single days matter.
Done when the component renders like the example in light and dark mode and the project type-checks.Usage
import { Heatmap } from "@/components/ui/heatmap";
// Made-up activity for 2026: quiet weekends, busier towards the end of each month.
const DATA = Array.from({ length: 365 }, (_, index) => {
const date = new Date(Date.UTC(2026, 0, 1 + index));
const weekend = date.getUTCDay() === 0 || date.getUTCDay() === 6;
const wave = (Math.sin(index / 9) + 1) * 2 + (index * 7) % 5;
const value = weekend ? ((index * 3) % 4 === 0 ? 1 : 0) : Math.max(0, Math.round(wave) - ((index * 11) % 3 === 0 ? 4 : 0));
return { date: date.toISOString().slice(0, 10), value };
});
export default function HeatmapDefault() {
return <Heatmap className="w-full" title="Your progress timeline for 2026" data={DATA} formatDay={(date, value) => `${date.toISOString().slice(0, 10)}: ${value} lessons`} />;
}Props
Heatmap
The calendar.
| Prop | Type | Default | Description |
|---|---|---|---|
| data | { date, value }[] | – | One entry per day, with ISO dates. |
| title | string | – | What the map shows. |
| formatDay | (date: Date, value: number) => string | – | Text of the hover label. |
Accessibility
Renders a single image whose name is the title plus the number of active days. Pair it with a list or table when single days matter.
Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.