Skip to content
Thrum

Cohort grid

Retention by cohort: one row per group of users who started together, one column per period since, and the share still active written in every cell over a colour that deepens with it. Read down a column to compare cohorts at the same age. For any other matrix, use the heatmap.

Install

npx shadcn@latest add @thrum-pro/cohort-grid

This is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.

Data shape

Type
type CohortGridCohort = {
  name: string;
  size: number;                  // users at the start
  retained: (number | null)[];   // still active per period
};
Sample
[
  { name: "6 Oct", size: 1240, retained: [1240, 520, 410, 352] },
  { name: "13 Oct", size: 1385, retained: [1385, 601, 470] },
]

Props

PropTypeDefaultDescription
periodsreadonly string[]RequiredNames of the periods, the column headers, from period 0.
cohortsreadonly CohortGridCohort[]RequiredOne row per cohort, oldest first. Each cell is retained divided by size. A retained list shorter than the periods leaves the rest of the row empty: those periods are not reached yet. A null is a period with no data, written as a dash.
labelstringRequiredWhat the table shows. Used as its caption and as the name of its scrolling region.
colorstringDefault var(--chart-1)Any CSS colour. Each cell is this colour mixed into the card colour, from 6% at 0% retained to 60% at 100%. Mixing into the card turns the scale round in a dark theme, so a higher share is always the more intense cell.
averagebooleanDefault trueAdd an Average row at the foot: for each period, the users retained over all cohorts that reached it, divided by those cohorts' sizes added up. Its size cell is the total of all cohorts.
cohortLabelstringDefault "Cohort"Header of the first column.
sizeLabelstringDefault "Users"Header of the size column.
formatIntl.NumberFormatOptionsDefault { maximumFractionDigits: 0 }How cohort sizes are written. Shares are always whole percentages.
localestringDefault "en-US"Locale for numbers. Fixed by default so the server and the browser print the same text.
emptyLabelstringDefault "No data"Text shown when there are no cohorts.
classNamestring–Sets the width; the default is full width. A table wider than its box scrolls sideways inside it, with the cohort column kept in view.

Motion and sound

Motion

  • Nothing moves. New data replaces the cells at once.

Sound

Silent. This component makes no sound.

Accessibility

  • It is a real table with a caption, column headers for the periods and row headers for the cohorts, so a screen reader can move cell by cell and hear both headers. It is its own text alternative; there is no hidden copy.
  • Every cell carries its share as text. The colour reinforces it: the strong end of the scale stops at 60% of the colour, where the number keeps 4.5:1 against its fill in a light and a dark theme.
  • A period with no data reads “No data”; a period not reached yet is an empty cell.
  • The scrolling region is named by the label and is a tab stop, so it can be scrolled with the keyboard. The cohort column stays in view while it scrolls.
  • The table frame is a panel surface: under a glass material it turns translucent like a card. The cohort column keeps the solid card colour, so the cells that slide under it stay hidden.
KeysAction
TabFocus the table's scrolling region.
← →Scroll the table sideways when it is wider than its box.

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/cohort-grid.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