Skip to content

Heatmap

A grid of values on two axes, such as weekday by hour. Each cell mixes your accent into the track by its value, so the pattern shows at a glance in light and dark.

On this page
Used for
  • Agent runs by weekday and hour
  • Tokens by region and month
  • Errors by service and day
  • Any two-axis count where the pattern matters more than the exact number

Examples

Any accent

Empty cells and a pinned scale

Follow the active cell

Installation

npx knowns-ui@latest add heatmap
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

rows / columnsrequired
string[]
The two axes: one label per row, top to bottom, and per column, left to right.
valuesrequired
(number | null)[][]
values[row][column]. null or a missing value is no data: an empty cell and a spoken no data.
labelrequired
string
Names the grid for assistive tech.
min / max
number
Default0 / highest
The ends of the scale. Pin max to compare several grids with the same colours.
format
(n) => string
Defaultgrouped integers
The text of a value, in the legend and for screen readers.
columnLabelEvery
number
Default1
Show only every nth column label. The full name is still read out.
legend
boolean
Defaulttrue
The Less to More strip under the grid.
size
"sm" | "md"
Default"md"
Cell height, 20 or 28 px.
narrow
{ bucket, below?, columnLabelEvery?, aggregate? }
Under `below` px (480) merge every `bucket` columns into one, so 24 hours fit as 12 two-hour columns without scrolling. aggregate: sum (default), mean or max. Labels then count buckets. A pinned max applies to the merged values.
minCellWidth
number
Default22
The narrowest a column gets, in px, before the grid scrolls sideways.
active / onActiveChange
HeatCell | null / HeatActive | null
The cell that is pointed at or focused, as shown. onActiveChange also gets the source columns it covers (from, to) and its value.
onCellSelect
(cell, value) => void
Enter, Space or a click on a cell.
Colour
color-mix
The accent (--kn-accent, else --primary) mixed into --muted by value: 12% for the smallest value up to 100% for the top. 0 and no data stay on the track.
Keyboard
grid
One tab stop. Arrow keys move one cell, Home and End the row ends, Ctrl and Home or End the corners, Page Up and Page Down the column ends. Each cell is read out as row, column and value.
Motion
colour
Pointing at or focusing a cell rings it and brightens its labels in 120 ms, colour only. Nothing plays on first render.

What it handles

  1. 01Mixes the accent into the track by each value, so the colours follow light and dark and your accent without a palette.
  2. 02Pins the top of the scale with max so two grids can be compared, or follows the highest value when you leave it out.
  3. 03Shows a missing value as an empty cell, never as the lowest colour, and says no data to a screen reader.
  4. 04Moves between cells with the arrow keys from one tab stop, with Home, End, Page Up and Page Down, and reads out the row, the column and the value.
  5. 05Rings the cell you point at or focus and brightens its two labels, with colour only.
  6. 06Scrolls sideways under a minimum column width instead of squashing the cells on a phone.

States

Point or focus
The cell is ringed and its row and column labels brighten
120ms, colour only
No data
The cell is an empty track colour, announced as no data
none
First render
Nothing plays
none
Reduced motion
Colour changes land at once
0ms

Works with

When to use

When to use

  • Showing where a count piles up across two axes, such as agent runs by weekday and hour or tokens by region and month.
  • A pattern the eye should catch before any number: the working-hours peak, the quiet weekend, the one hot cell.

When not to use

  • A trend of one number over time: use Chart.
  • Status day by day for one service: use Uptime Bar.
  • A card with a total, a change and a period switch around the grid: use Heatmap Card.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Heatmap to my app and wire it to my own data.
  • I need showing where a count piles up across two axes, such as agent runs by weekday and hour or tokens by region and month. Set that up with the Knowns UI Heatmap.
  • Which Heatmap props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "heatmap" }) and search_docs({ query: "heatmap" }).

Need help?

Stuck on Heatmap, or found something off? We read every message.