Skip to content
Thrum

Heatmap

A table of numbers read as colour: one cell per pair of row and column, on a scale of one hue. Use it to find the busy hours of a week or the strong pairs in a matrix. For daily values over a year, use the calendar heatmap; for retention by cohort, use the cohort grid.

Install

npx shadcn@latest add @thrum-pro/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
rows: string[];
columns: string[];
values: (number | null)[][]; // values[row][column]
Sample
[
  [12, 48, 61, 37],
  [15, 52, null, 41],
]

Props

PropTypeDefaultDescription
rowsreadonly string[]RequiredNames of the rows, top to bottom. Names longer than a third of the width end in an ellipsis; the readout and the table carry them in full.
columnsreadonly string[]RequiredNames of the columns, left to right. Every nth name is shown so the widest has room.
valuesreadonly (readonly (number | null)[])[]RequiredOne list per row with one value per column. A null, or a value that is not there, is a missing cell: hatched, and read as “No data”.
labelstringRequiredWhat the values measure. Read by screen readers and used as the table caption.
colorstringDefault var(--chart-1)Any CSS colour. Cells are this colour mixed into the background, from 6% at the low end up. Mixing into the background turns the scale round in a dark theme, so a higher value is always the more intense cell.
minnumberDefault lowest valueThe value at the faint end of the scale. Values below it are drawn at the faint end.
maxnumberDefault highest valueThe value at the strong end of the scale. Values above it are drawn at the strong end.
showValuesbooleanDefault trueWrite each value in its cell, when the widest one fits a cell and cells are at least 16 pixels tall. With values on, the strong end stops at 60% of the colour so the text keeps 4.5:1 in both themes; with values off it reaches full strength.
legendbooleanDefault trueShow the colour scale under the grid with its ends and a round value between, and a hatched swatch when a cell is missing.
formatIntl.NumberFormatOptionsDefault compactHow values are written in cells, on the scale, in the readout and in the data table.
localestringDefault "en-US"Locale for numbers. Fixed by default so the server and the browser print the same text.
onActiveChange(index: number | null) => void–Called with the index of the cell under the cursor, counted row by row (row × columns + column), or null when the cursor leaves.
soundbooleanDefault truePlay a tick as the cursor moves between cells, if the visitor has sound on.
emptyLabelstringDefault "No data"Text shown when no cell has a value.
classNamestring–Sets the size. The default is full width and 288 pixels tall, scale included. The cells share the room left after the names.

Motion and sound

Motion

  • First draw: the columns fade in left to right in 250 ms each, at most 300 ms apart from first to last.
  • New data: cells take their new colour at once. A grid of another size is drawn again at once.
  • The ring around the active cell follows the pointer on a stiff spring.
  • Reduced motion: the grid appears complete, and the cursor moves instantly.

Sound

  • A soft tick each time the cursor lands on a different cell, 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 whose value text is the cell under the cursor, for example “Tue, 10:00: 52”.
  • A visually hidden table carries every value with row and column headers.
  • Colour is a reinforcement: values are written in the cells where they fit, and the readout always gives the number. Missing cells are hatched, never just pale, so they cannot be read as low values.
  • The whole grid is the pointer target; a pointer in a gap reads the cell beside it.
KeysAction
TabFocus the grid. The cursor goes to the last cell.
← →Move the cursor one column. It stops at the edge.
↑ ↓Move the cursor one row. It stops at the edge.
Home / EndJump to the first or the last cell.
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/heatmap.tsx
Packages
motion
Brings along
Chart foundationsMotion tokensSound engine

Changelog

  1. 1.0.0 · 2026-12-03First 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