Calendar heatmap
A year of daily values as a grid of weeks by weekdays, coloured in steps of one hue. Use it to show rhythm over a long span: commits, logins, deploys, workouts. For the exact shape of one metric over time, use the area chart.
Install
npx shadcn@latest add @thrum-pro/calendar-heatmapThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Data shape
type CalendarHeatmapDay = {
date: string; // ISO date, "2026-03-14"
value: number | null; // null = no data
};[
{ date: "2026-03-13", value: 12 },
{ date: "2026-03-14", value: 0 },
{ date: "2026-03-15", value: null },
{ date: "2026-03-17", value: 7 },
]Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | readonly CalendarHeatmapDay[] | Required | One entry per day, in any order. The grid runs from the earliest date to the latest; a day in between that is not listed counts as no data. At most the latest 1,830 days are drawn. |
label | string | Required | What the values measure. Read by screen readers and used as the table caption. |
weekStart | 0 | 1 | Default 1 | The day at the top of each column: 0 for Sunday, 1 for Monday. |
color | string | Default var(--chart-1) | Any CSS colour. Cells step from an 18% mix of it with the background up to the colour itself. |
levels | number | Default 5 | How many colour steps, from 2 to 9. The faintest step holds zero, or the lowest value when some are negative; the rest split the range up to the highest value evenly. |
format | Intl.NumberFormatOptions | Default compact | How values are written in the readout and in the data table. |
locale | string | Default "en-US" | Locale for numbers, month names, weekday initials and the date in the readout. |
onActiveChange | (index: number | null) => void | – | Called with the number of days between the first date and the day under the cursor, or null when the cursor leaves. |
sound | boolean | Default true | Play a tick as the cursor moves between days, if the visitor has sound on. |
emptyLabel | string | Default "No data" | Text shown when no day has a value. |
className | string | – | Sets the size. The default is full width and 144 pixels tall. Cells are as large as the height and the width both allow, and never smaller than 10 pixels. |
Motion and sound
Motion
- First draw: the week columns fade in one after another, oldest first. The whole wave takes at most 550 ms.
- New values: cells take their new colour at once. Nothing moves.
- The ring around the active day and its readout follow the cursor on a stiff spring.
- Reduced motion: every cell is there in the first frame, and the cursor moves instantly.
Sound
- A soft tick each time the cursor lands on a different day, at most one every 40 ms.
Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works
Accessibility
- The grid is one tab stop. It is exposed as a slider over the days, whose value text is the day under the cursor, for example “Sat, Mar 14, 2026: 12”. A day without a value reads “no data”.
- A visually hidden table carries one row per day, with the label as its caption.
- Zero and no data are different shapes, not different shades: zero is a filled cell on the faintest step, no data is an empty outline.
- When the weeks do not fit, the grid scrolls sideways inside the component and opens on the most recent week. The keyboard cursor scrolls its day into view.
- Dates are read as UTC days, so the grid is the same in every time zone.
| Keys | Action |
|---|---|
| Tab | Focus the grid. The cursor goes to the latest day. |
| ← → | Move the cursor one week. |
| ↑ ↓ | Move the cursor one day. |
| Home / End | Jump to the first or last day. |
| Esc | Hide the cursor. |
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/calendar-heatmap.tsx- Packages
motion- Brings along
- Chart foundationsMotion tokensSound engine
Changelog
- 1.0.1 · 2026-12-03Corners follow the project's --radius, down to square.
- 1.0.0 · 2026-12-02First release.