Heatmap
A contribution grid of slanted-pixel days.
Demo
Usage
import { Heatmap } from '@tuttn/slant'
// One entry per day, as an ISO date; days in the range with no entry count as 0.
const data = [{ date: '2026-05-04', value: 3 }, { date: '2026-05-05', value: 7 }, /* … */]
<Heatmap data={data} label="Commits, May to October 2026" unit="commits" />
// A fixed range, weeks from Sunday, three colour steps that top out at 10.
<Heatmap data={data} label="Deploys this quarter" unit="deploys"
start="2026-07-01" end="2026-09-30" weekStartsOn={0} levels={3} max={10} />
// The cursor keeps its own day, starting from the last one. Start it elsewhere
// and hear about moves, or pass `active` to hold it yourself.
<Heatmap data={data} label="Commits" defaultActive="2026-10-01" onActiveChange={setDay} />Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | HeatmapDatum[] | — | The days and their values, in any order. |
label | string | — | The chart's accessible name. |
unit | string | — | Read after each value, e.g. "commits". |
format | (value: number) => string | value => String(value) | Formats each value in the readout, the table and announcements. |
start | string | the data's first day | The first day shown, as an ISO date. |
end | string | the data's last day | The last day shown, as an ISO date. |
weekStartsOn | 0 | 1 | 1 | The day at the top of each week's column: 1 for Monday, 0 for Sunday. |
locale | string | 'en' | For the month and weekday names and the dates read out. |
levels | number | 4 | How many colour steps sit above an empty day. |
max | number | the largest value shown | The value that reaches the top step; larger values draw there too. |
table | boolean | false | Shows the data table under the chart. It is always there for screen readers. |
active | string | — | The day the keyboard cursor sits on, as an ISO date, for a controlled chart. |
defaultActive | string | the last day | The day the keyboard cursor starts on, as an ISO date. |
onActiveChange | (date: string) => void | — | Called with the day, as an ISO date, when the keyboard moves the cursor. |
…rest | HTMLAttributes<HTMLDivElement> | — | className, style, other attributes and the ref go on the root. |
Each column is a week and each row a weekday, starting on Monday (weekStartsOn={0} for Sunday). Dates are read as UTC days, so a range never shifts with the reader's time zone or a daylight-saving change. The days before start and after end that fill out the first and last weeks are left blank.
The colour ramp runs from the raised surface (--sl-surface-2, an empty day) to the theme's accent, in levels steps mixed in oklab, so its lightness moves one way in every theme: up in the dark ones, down in Paper. A day's step is its share of max, the largest value by default. The key under the grid shows the steps from messages.fewer to messages.most.
The grid is one tab stop, named by label and described by a text summary of the range and its highest and lowest day. Up and Down move a day within the week, Left and Right a week, Home and End to the first and last day; nothing wraps, the blank days are skipped, and every move is announced with the day's full date and value. Hovering a day shows it in the readout under the grid without moving the cursor; otherwise the readout shows the total. The month and weekday names, the readout and the key are visual only. The data table is always there for screen readers, and table shows it.
The grid is physical, like every chart: under dir="rtl" the weeks still run from left to right and Right still moves to the next week. The readout and the key follow the reading direction. Month and weekday names follow locale. When the weeks outrun the container, the grid scrolls sideways and keeps the cursor's week in view.