Heatmap
Heatmap for values across two dimensions: a weekday × hour matrix, a contribution calendar, a punch card, labelled cells and a correlation matrix.
Playground
Installation
Heatmap comes with WunderUI Core and Pro, in the package from your plan. See the plans.
The charts live in their own entry point: import the chart, its card and its hooks from @wunderui/react/charts, not from @wunderui/react.
Then import what you need:
import {
HeatmapChart,
HeatmapChartProps,
HeatmapChartVariant,
} from "@wunderui/react/charts"Then use it:
import { HeatmapChart } from "@wunderui/react/charts"
const matrix = [
[4, 12, 30, 18],
[6, 15, 34, 20],
[2, 5, 9, 4],
]
export function TicketsByHour() {
return (
<HeatmapChart
matrix={matrix}
rowLabels={["Mon", "Tue", "Sat"]}
columnLabels={["6:00", "12:00", "18:00", "24:00"]}
label="Tickets by weekday and hour"
/>
)
}Expected result: You see a grid of three rows and four columns, darker where the value is higher.
When to use
Use Heatmap for
- A value for each row and column: weekday by hour, a contribution calendar
- A correlation matrix on a diverging scale
- A punch card, where the size of a circle replaces colour
Use something else for
- Bubble Chart for the relation between two measures
- Bar Chart for values along one dimension
- Treemap for parts of a hierarchy
- Distribution Chart for how one measure spreads
States
Loading, empty and error keep the chart's size, so the card never jumps. Add a retry handler and the error state offers a Try again button.
Keyboard interactions
The plot is focusable: arrow keys walk the cells in reading order, and the live region reads row, column and value (like Mon, 9am: 12), or no value for an empty cell.
- TaborShiftTab
- Moves focus to the plot and away from it. The plot is one tab stop; so is every legend badge.
- ArrowRightorArrowLeft
- Moves to the next or previous cell. The tooltip follows, and a live region announces the one you are on. The first press starts at the first one (Left: the last one).
- HomeorEnd
- Jumps to the first or last cell.
- Escape
- Clears the active point.
- EnterorSpace
- On a legend badge of a ChartCard: switches its series off or on. The last visible series stays on.
Behavior and motion
What the chart does on its own and what the page decides.
- Matrix
- The matrix is a list of rows of values, with null for no data. Row and column labels name them, and the column tick setting thins the labels when there are many.
- Colour
- Tint grows with value, and a null cell uses the muted colour, not a low value. The correlation matrix uses a diverging scale: blue for positive, red for negative.
- Cell values
- The labelled heatmap and correlation matrix write the value in each cell, in a text colour that keeps contrast. When cells are too small, only the hovered or focused one shows its value.
- Scale legend
- A Less to More strip sits under the grid, and you can hide it or add a caption such as 2,384 contributions in 2026.
- Loading, empty and error
- The chart keeps its size while loading, empty or failed, so the card never changes height. Add a retry handler to show a Try again button on error.
- Size
- The chart fills the width of its container, and you set the plot height. Text never scales: labels keep their size at every width.
Motion
The enter sequence and hover follow the library's motion tokens.
- Fade in
- Cells fade in from left to right the first time the chart is in view, and again after loading or when new data arrives. You can turn it off.
- Reduced motion
- With reduced motion the enter sequence is off and the chart appears at once. Tooltip, crosshair and every state still work.
Anatomy
HeatmapChart shows a value for each row and column as colour: a weekday by hour grid, a contribution calendar, a punch card, labelled cells or a correlation matrix. Pass the grid as a matrix.
Support tickets
| Row · column | Value |
|---|---|
| Mon · 0:00 | 1 |
| Mon · 3:00 | 9 |
| Mon · 6:00 | 26 |
| Mon · 9:00 | 45 |
| Mon · 12:00 | 70 |
| Mon · 15:00 | 73 |
| Mon · 18:00 | 45 |
| Mon · 21:00 | 23 |
| Tue · 0:00 | 8 |
| Tue · 3:00 | 7 |
| Tue · 6:00 | 24 |
| Tue · 9:00 | 52 |
| Tue · 12:00 | 68 |
| Tue · 15:00 | 71 |
| Tue · 18:00 | 52 |
| Tue · 21:00 | 21 |
| Wed · 0:00 | 6 |
| Wed · 3:00 | 14 |
| Wed · 6:00 | 22 |
| Wed · 9:00 | 50 |
| Wed · 12:00 | 75 |
| Wed · 15:00 | 69 |
| Wed · 18:00 | 50 |
| Wed · 21:00 | 28 |
| Thu · 0:00 | 4 |
| Thu · 3:00 | 12 |
| Thu · 6:00 | 20 |
| Thu · 9:00 | 48 |
| Thu · 12:00 | 73 |
| Thu · 15:00 | 67 |
| Thu · 18:00 | 48 |
| Thu · 21:00 | 26 |
| Fri · 0:00 | 2 |
| Fri · 3:00 | 10 |
| Fri · 6:00 | 27 |
| Fri · 9:00 | 46 |
| Fri · 12:00 | 71 |
| Fri · 15:00 | 74 |
| Fri · 18:00 | 46 |
| Fri · 21:00 | 24 |
| Sat · 0:00 | 8 |
| Sat · 3:00 | 4 |
| Sat · 6:00 | 12 |
| Sat · 9:00 | 24 |
| Sat · 12:00 | 25 |
| Sat · 15:00 | 28 |
| Sat · 18:00 | 24 |
| Sat · 21:00 | 9 |
| Sun · 0:00 | 6 |
| Sun · 3:00 | 2 |
| Sun · 6:00 | 10 |
| Sun · 9:00 | 22 |
| Sun · 12:00 | 23 |
| Sun · 15:00 | 26 |
| Sun · 18:00 | 22 |
| Sun · 21:00 | 7 |
Takes a matrix of rows by columns (null for no data) plus row and column labels. Options thin the column labels, set the colour scale, add a caption and toggle the Less to More legend.
- data-slot="chart-plot"
The focusable region. Arrow keys walk the marks and the live region reads each one as the tooltip shows it.
- data-slot="chart-marks"
One rounded cell per value, fading in from left to right. Tint grows with value and a null cell uses the muted colour, not a low value; the hovered cell gets an outline.
- data-slot="chart-value-active"
The number inside each cell on the labelled heatmap and correlation matrix, in a text colour that keeps contrast. When cells are too small, only the hovered or focused cell shows its value.
The Less to More strip under the grid (a -1 to +1 strip on the correlation matrix, blue positive and red negative), plus a caption such as 2,384 contributions in 2026.
- data-slot="chart-tooltip"
Row and column labels as the title, then the cell value.
- data-slot="chart-message"
Muted bars as the placeholder under the shimmer. A matrix with no numbers counts as empty, and you can reword the message with a custom title and description.
A table of every cell for screen readers.
Best practices
- Do
Use one hue per measure (indigo by default, green on the calendar) so lightness is the only variable. Use diverging blue and red only for values around zero, like correlations.
- Do
Use the labelled heatmap when people need the number, and the punch card when a cell has a count and a rate. Colour alone is a rough read.
- Do
Pass null for missing data, not 0. A zero is a measurement and is drawn as the lowest step.
- Don’t
Don't compare two heatmaps with different maxima. Each one scales to its own largest value, so the same colour means different numbers.
- Don’t
Don't go beyond about 7 by 24 cells without thinning the column labels. Dense labels overlap and the grid stops being readable.
API reference
One table for HeatmapChart, listing every prop. The ChartCard around it takes its own props (title, legend, periods, table and more), and the chart works without one.
Takes a matrix of rows by columns (null for no data) plus row and column labels. Options thin the column labels, set the colour scale, add a caption and toggle the Less to More legend.
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("heatmap")The full library index for assistants is at /llms.txt.