HeatmapPro
A color-scaled grid with row and column tracking, for cohorts and schedules.
$
pnpm dlx shadcn@latest add @lode/heatmapLive preview
Busiest hours
| 9a | 11a | 1p | 3p | 5p | 7p | 9p | |
|---|---|---|---|---|---|---|---|
| Mon | 74 | 92 | 100 | 97 | 84 | 62 | 34 |
| Tue | 100 | 84 | 34 | 62 | 97 | 91 | 48 |
| Wed | 84 | 35 | 97 | 74 | 49 | 100 | 61 |
| Thu | 34 | 97 | 48 | 92 | 61 | 84 | 73 |
| Fri | 62 | 74 | 92 | 34 | 100 | 50 | 83 |
| Sat | 51 | 32 | 37 | 52 | 42 | 25 | 48 |
| Sun | 49 | 52 | 46 | 32 | 25 | 41 | 51 |
When to use
- Cohort retention, activity by hour and day, any grid of magnitudes.
When not to use
- A single row: use a bar chart.
Installation
$
pnpm dlx shadcn@latest add @lode/heatmapPro components need an API key and the registry in components.json. See CLI and API keys.
1Install the dependencies
npm install motion2Copy the source into your project
Usage
Import it from @/components/ui/heatmap after installing.
example.tsx
import { Heatmap } from "@/components/ui/heatmap";
export function Retention({ rows }: { rows: { label: string; values: (number | null)[] }[] }) {
return <Heatmap rows={rows} columns={["M0", "M1", "M2"]} max={100} />;
}API reference
Heatmap
A table of color-scaled cells.
rows
{ label; values: (number|null)[]; meta? }[]
null leaves a cell empty.
columns
string[]
Column headers.
max / format / color
number / (n) => string / string
Scale top, cell text and color.
metaLabel
string
Header for the meta column, e.g. cohort size.
| Prop | Type | Default | Description |
|---|---|---|---|
| rows | { label; values: (number|null)[]; meta? }[] | – | null leaves a cell empty. |
| columns | string[] | – | Column headers. |
| max / format / color | number / (n) => string / string | – | Scale top, cell text and color. |
| metaLabel | string | – | Header for the meta column, e.g. cohort size. |
Accessibility
- A real <table>; each cell's value is printed, so color isn't the only signal.
Motion
- Cells pop in along the diagonal; hover highlights the row and column.
Responsive behavior
- Scrolls horizontally inside its container on narrow screens.
Performance
- One cell per value; fine up to a few hundred cells.
Notes for AI
- Use null, not 0, for periods that haven't happened yet.
This page as Markdown, for assistants and coding agents:
/components/heatmap/markdownThe full library index for assistants is at /llms.txt.
Related
Lode·229 doc pages·llms.txt