Week 1 return rose from 52% to 56%
Weekly cohorts since 14 Sep
| Cohort | W11 | W22 | W33 | W44 | W55 | W66 | W77 | W88 | W99 |
|---|---|---|---|---|---|---|---|---|---|
| 14 Sep, 1,334 | 52% | 45% | 37% | 36% | 27% | 26% | 23% | 18% | 16% |
| 21 Sep, 1,370 | 56% | 48% | 43% | 35% | 29% | 24% | 25% | 19% | |
| 28 Sep, 1,188 | 52% | 44% | 42% | 36% | 28% | 25% | 22% | ||
| 5 Oct, 1,241 | 56% | 47% | 43% | 33% | 34% | 28% | |||
| 12 Oct, 1,256 | 56% | 49% | 42% | 38% | 30% | ||||
| Average | 54% | 47% | 41% | 36% | 30% | 26% | 23% | 19% | 16% |
formatminfooterimport { HeatTable } from "@/components/ui/heat-table"
import { cohorts, weeks, averages } from "./cohorts"
export function Retention() {
return (
<HeatTable
aria-label="Weekly return by cohort"
columns={weeks}
phoneColumns={weeks.map((_, w) => String(w + 1))}
rows={cohorts}
rowHeader="Cohort"
format={(v) => `${v}%`}
label={(c) => `${c.row.label} cohort, week ${c.columnIndex + 1}: ${c.value}%`}
footer={{ label: "Average", values: averages(cohorts).map((v) => `${v}%`) }}
/>
)
}Usage
import { HeatTable } from "@/components/ui/heat-table"
const cohorts = [
{ label: "14 Sep", meta: "1,334", values: [52, 45, 37] },
{ label: "21 Sep", meta: "1,370", values: [56, 48] },
{ label: "28 Sep", meta: "1,188", values: [52] },
]
export function Retention() {
return (
<HeatTable
aria-label="Weekly return by cohort"
columns={["W1", "W2", "W3"]}
rows={cohorts}
rowHeader="Cohort"
format={(v) => `${v}%`}
/>
)
}Examples
Week 1 return rose from 52% to 61%
Weekly cohorts since 14 Sep
| Cohort | W11 | W22 | W33 | W44 | W55 | W66 | W77 | W88 | W99 |
|---|---|---|---|---|---|---|---|---|---|
| 14 Sep, 1,334 | 52% | 45% | 37% | 36% | 27% | 26% | 23% | 18% | 16% |
| 21 Sep, 1,370 | 56% | 48% | 43% | 35% | 29% | 24% | 25% | 19% | |
| 28 Sep, 1,188 | 52% | 44% | 42% | 36% | 28% | 25% | 22% | ||
| 5 Oct, 1,241 | 56% | 47% | 43% | 33% | 34% | 28% | |||
| 12 Oct, 1,256 | 56% | 49% | 42% | 38% | 30% | ||||
| 19 Oct, 1,392 | 54% | 51% | 41% | 35% | |||||
| 26 Oct, 1,205 | 59% | 50% | 41% | ||||||
| 2 Nov, 1,034 | 57% | 52% | |||||||
| 9 Nov, 929 | 61% | ||||||||
| Average | 56% | 48% | 41% | 35% | 30% | 26% | 23% | 19% | 16% |
import { HeatTable } from '@/components/ui/heat-table';
const cohorts = [
{ label: '14 Sep', size: 1334, meta: '1,334', values: [52, 45, 37, 36, 27, 26, 23, 18, 16] },
{ label: '21 Sep', size: 1370, meta: '1,370', values: [56, 48, 43, 35, 29, 24, 25, 19] },
{ label: '28 Sep', size: 1188, meta: '1,188', values: [52, 44, 42, 36, 28, 25, 22] },
// ...one row per weekly cohort
];
const weeks = ['W1', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8', 'W9'];
export function Example() {
return (
<HeatTable
aria-label="Weekly return by cohort"
columns={weeks}
phoneColumns={weeks.map((_, w) => String(w + 1))}
rows={cohorts}
rowHeader="Cohort"
format={(v) => `${v}%`}
label={(c) => `${c.row.label} cohort, week ${c.columnIndex + 1}: ${c.value}%`}
footer={{ label: 'Average', values: ['56%', '48%', '41%', '35%', '30%', '26%', '23%', '19%', '16%'] }}
/>
);
}Week 1 return rose from 52% to 61%
Weekly cohorts since 14 Sep
| Cohort | W11 | W22 | W33 | W44 | W55 | W66 | W77 | W88 | W99 |
|---|---|---|---|---|---|---|---|---|---|
| 14 Sep, 1,334 | 52% | 45% | 37% | 36% | 27% | 26% | 23% | 18% | 16% |
| 21 Sep, 1,370 | 56% | 48% | 43% | 35% | 29% | 24% | 25% | 19% | |
| 28 Sep, 1,188 | 52% | 44% | 42% | 36% | 28% | 25% | 22% | ||
| 5 Oct, 1,241 | 56% | 47% | 43% | 33% | 34% | 28% | |||
| 12 Oct, 1,256 | 56% | 49% | 42% | 38% | 30% | ||||
| 19 Oct, 1,392 | 54% | 51% | 41% | 35% | |||||
| 26 Oct, 1,205 | 59% | 50% | 41% | ||||||
| 2 Nov, 1,034 | 57% | 52% | |||||||
| 9 Nov, 929 | 61% | ||||||||
| Average | 56% | 48% | 41% | 35% | 30% | 26% | 23% | 19% | 16% |
import { useState } from 'react';
import { HeatTable } from '@/components/ui/heat-table';
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group';
import { cohorts, weeks } from './cohorts';
export function Example() {
const [values, setValues] = useState('percent');
const people = (c) => Math.round((c.row.size * c.value) / 100);
return (
<>
<ToggleGroup aria-label="Values" value={[values]} onValueChange={(next) => next[0] && setValues(next[0])}>
<ToggleGroupItem value="percent">Percent</ToggleGroupItem>
<ToggleGroupItem value="people">People</ToggleGroupItem>
</ToggleGroup>
<HeatTable
columns={weeks}
rows={cohorts}
rowHeader="Cohort"
format={(v, c) => (values === 'people' ? people(c).toLocaleString('en-GB') : `${v}%`)}
readout={(c) => `${people(c)} of ${c.row.size} came back in week ${c.columnIndex + 1}`}
/>
</>
);
}Notes
One fact per shade
A cell's shade is the primary colour mixed into the surface by its place between min and max. Past the middle the text turns to the primary foreground, and the mix skips the band where neither text colour would reach 4.5:1. Use heatShade(amount) to shade a legend the same way.
Blank cells
A null value leaves its cell empty and out of the keyboard path, which gives cohort data its stair edge.
Phone
Below 768px the grid keeps its shape as squares with no numbers. Up to 12 columns share the width; past that each square keeps 28px and the grid scrolls sideways. Tapping a square rings it and fills the readout under the grid.
Large grids
Pointing at a cell lights its headers without rendering the grid again, and choosing a cell draws only the two rows it touches. For hundreds of rows set maxHeight and virtualize, so only the rows in view are in the page.
API
Wed 18 Nov 2026 over a printed 18. Defaults to columns.span columns, such as months over days.columns.label, optional meta shown after it on desktop, and values with one number per column. null leaves a cell blank.min to max.--heat-table-cell-width and --heat-table-cell-height for any other size.maxHeight is set. Sticky cells take --heat-table-surface, which defaults to --background.null as it leaves the grid.Accessibility
- An ARIA grid with one tab stop. Arrows move between cells, so the page's tab order passes it in one step.
- Each cell is named by its row, its column and its value, so a screen reader never has to work out the headers.
columnLabelsgives short printed columns a full spoken name. - The chosen cell carries
aria-selected. - The number is always printed on desktop, and named on every cell, so the shade is never the only signal.
- The phone readout is a polite live region, so tapping a square says what it holds.
- The lit row and column headers take a tint as well as the text colour, so they show even where muted text sits close to the foreground.
- Hover and focus rings respect reduced motion.