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 heatmapFor Claude Code, Cursor or Codex: installs it and wires the props to your own data.
Paste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install prompt
Install Heatmap from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/heatmap
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add heatmap
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- components/ui/knowns/heatmap/heatmap.tsx
- components/ui/knowns/heatmap/heatmap-utils.ts
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/heatmap, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "heatmap" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.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- Default
0 / highest - The ends of the scale. Pin max to compare several grids with the same colours.
- format
(n) => string- Default
grouped integers - The text of a value, in the legend and for screen readers.
- columnLabelEvery
number- Default
1 - Show only every nth column label. The full name is still read out.
- legend
boolean- Default
true - 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- Default
22 - 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.
| Prop | Type | Default | Description |
|---|---|---|---|
| rows / columnsrequired | string[] | required | The two axes: one label per row, top to bottom, and per column, left to right. |
| valuesrequired | (number | null)[][] | required | values[row][column]. null or a missing value is no data: an empty cell and a spoken no data. |
| labelrequired | string | required | Names the grid for assistive tech. |
| min / max | number | 0 / highest | The ends of the scale. Pin max to compare several grids with the same colours. |
| format | (n) => string | grouped integers | The text of a value, in the legend and for screen readers. |
| columnLabelEvery | number | 1 | Show only every nth column label. The full name is still read out. |
| legend | boolean | true | The Less to More strip under the grid. |
| size | "sm" | "md" | "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 | 22 | 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
- 01Mixes the accent into the track by each value, so the colours follow light and dark and your accent without a palette.
- 02Pins the top of the scale with max so two grids can be compared, or follows the highest value when you leave it out.
- 03Shows a missing value as an empty cell, never as the lowest colour, and says no data to a screen reader.
- 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.
- 05Rings the cell you point at or focus and brightens its two labels, with colour only.
- 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
| State | What moves | Timing |
|---|---|---|
| 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" }).