Skip to content
Thrum

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-heatmap

This is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.

Data shape

Type
type CalendarHeatmapDay = {
  date: string;         // ISO date, "2026-03-14"
  value: number | null; // null = no data
};
Sample
[
  { 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

PropTypeDefaultDescription
datareadonly CalendarHeatmapDay[]RequiredOne 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.
labelstringRequiredWhat the values measure. Read by screen readers and used as the table caption.
weekStart0 | 1Default 1The day at the top of each column: 0 for Sunday, 1 for Monday.
colorstringDefault var(--chart-1)Any CSS colour. Cells step from an 18% mix of it with the background up to the colour itself.
levelsnumberDefault 5How 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.
formatIntl.NumberFormatOptionsDefault compactHow values are written in the readout and in the data table.
localestringDefault "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.
soundbooleanDefault truePlay a tick as the cursor moves between days, if the visitor has sound on.
emptyLabelstringDefault "No data"Text shown when no day has a value.
classNamestring–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.
KeysAction
TabFocus the grid. The cursor goes to the latest day.
← →Move the cursor one week.
↑ ↓Move the cursor one day.
Home / EndJump to the first or last day.
EscHide the cursor.

Source

SourcePro

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. 1.0.1 · 2026-12-03Corners follow the project's --radius, down to square.
  2. 1.0.0 · 2026-12-02First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor