Skip to content

Cohort Retention Chart for React

A React cohort retention chart shows how many people from each starting week or month are still around. Pass data as readonly CohortRow[]: takes one row per cohort, oldest first.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/cohort-chart.json

Weekly retention by signup cohort

CohortWeek 0Week 1Week 2Week 3Week 4Week 5
AverageAll cohorts, weighted
100%, 11.4K of 11.4K users
45.5%, 5,178 of 11.4K users
34.0%, 3,872 of 11.4K users
29.0%, 3,297 of 11.4K users
25.6%, 2,919 of 11.4K users
22.8%, 2,237 of 11.4K users
Jan 51,284 users
100%, 1,284 of 1,284 users
43.6%, 560 of 1,284 users
31.1%, 399 of 1,284 users
27.7%, 356 of 1,284 users
23.4%, 300 of 1,284 users
20.0%, 257 of 1,284 users
Jan 121,342 users
100%, 1,342 of 1,342 users
42.5%, 570 of 1,342 users
32.9%, 442 of 1,342 users
26.5%, 356 of 1,342 users
25.1%, 337 of 1,342 users
21.8%, 292 of 1,342 users
Jan 191,190 users
100%, 1,190 of 1,190 users
44.4%, 528 of 1,190 users
31.8%, 378 of 1,190 users
28.3%, 337 of 1,190 users
23.9%, 285 of 1,190 users
23.5%, 280 of 1,190 users
Jan 261,415 users
100%, 1,415 of 1,415 users
46.3%, 655 of 1,415 users
33.6%, 476 of 1,415 users
27.1%, 384 of 1,415 users
25.7%, 364 of 1,415 users
22.3%, 315 of 1,415 users
Feb 21,502 users
100%, 1,502 of 1,502 users
45.2%, 679 of 1,502 users
35.6%, 534 of 1,502 users
29.0%, 436 of 1,502 users
24.5%, 368 of 1,502 users
24.0%, 361 of 1,502 users
Feb 91,468 users
100%, 1,468 of 1,468 users
47.1%, 691 of 1,468 users
34.4%, 505 of 1,468 users
30.9%, 453 of 1,468 users
26.4%, 387 of 1,468 users
22.8%, 335 of 1,468 users
Feb 161,610 users
100%, 1,610 of 1,610 users
46.0%, 741 of 1,610 users
36.3%, 584 of 1,610 users
29.7%, 478 of 1,610 users
28.1%, 453 of 1,610 users
24.7%, 397 of 1,610 users
Feb 231,575 users
100%, 1,575 of 1,575 users
47.9%, 754 of 1,575 users
35.2%, 554 of 1,575 users
31.6%, 497 of 1,575 users
27.0%, 425 of 1,575 users
Not yet reached

Use the arrow keys to move between cells; Home and End jump along a row, Ctrl+Home and Ctrl+End to the corners.

  • CohortChart
  • CohortTable
  • cohortModel
  • cohortPercent
  • defaultCohortChartLabels
  • +3 more

Weekly cohorts

Twelve weekly signup cohorts. Switch between percentages and user counts: one glint sweeps the new numbers in, and the colors stay on retention so cohorts of different sizes stay comparable. Tab into the grid and use the arrow keys; Ctrl+Home / Ctrl+End jump to the corners.

Weekly retention

Signups from Jan 5 to Mar 23, 2026

25.6%week-4 retention
CohortWeek 0Week 1Week 2Week 3Week 4Week 5Week 6Week 7Week 8Week 9Week 10Week 11
AverageAll cohorts, weighted
100%, 18.3K of 18.3K users
46.8%, 7,716 of 18.3K users
34.9%, 5,146 of 18.3K users
29.1%, 3,814 of 18.3K users
25.6%, 2,919 of 18.3K users
22.8%, 2,237 of 18.3K users
21.1%, 1,727 of 18.3K users
19.4%, 1,307 of 18.3K users
18.0%, 939 of 18.3K users
17.1%, 651 of 18.3K users
15.3%, 401 of 18.3K users
15.6%, 200 of 18.3K users
Jan 51,284 users
100%, 1,284 of 1,284 users
43.6%, 560 of 1,284 users
31.1%, 399 of 1,284 users
27.7%, 356 of 1,284 users
23.4%, 300 of 1,284 users
20.0%, 257 of 1,284 users
20.2%, 259 of 1,284 users
17.7%, 227 of 1,284 users
18.5%, 237 of 1,284 users
16.4%, 210 of 1,284 users
14.4%, 185 of 1,284 users
15.6%, 200 of 1,284 users
Jan 121,342 users
100%, 1,342 of 1,342 users
42.5%, 570 of 1,342 users
32.9%, 442 of 1,342 users
26.5%, 356 of 1,342 users
25.1%, 337 of 1,342 users
21.8%, 292 of 1,342 users
18.9%, 253 of 1,342 users
19.4%, 260 of 1,342 users
17.1%, 230 of 1,342 users
18.0%, 242 of 1,342 users
16.1%, 216 of 1,342 users
Not yet reached
Jan 191,190 users
100%, 1,190 of 1,190 users
44.4%, 528 of 1,190 users
31.8%, 378 of 1,190 users
28.3%, 337 of 1,190 users
23.9%, 285 of 1,190 users
23.5%, 280 of 1,190 users
20.6%, 245 of 1,190 users
18.1%, 215 of 1,190 users
18.8%, 224 of 1,190 users
16.7%, 199 of 1,190 users
Not yet reached
Not yet reached
Jan 261,415 users
100%, 1,415 of 1,415 users
46.3%, 655 of 1,415 users
33.6%, 476 of 1,415 users
27.1%, 384 of 1,415 users
25.7%, 364 of 1,415 users
22.3%, 315 of 1,415 users
22.4%, 317 of 1,415 users
19.9%, 281 of 1,415 users
17.5%, 248 of 1,415 users
Not yet reached
Not yet reached
Not yet reached
Feb 21,502 users
100%, 1,502 of 1,502 users
45.2%, 679 of 1,502 users
35.6%, 534 of 1,502 users
29.0%, 436 of 1,502 users
24.5%, 368 of 1,502 users
24.0%, 361 of 1,502 users
21.1%, 317 of 1,502 users
21.6%, 324 of 1,502 users
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Feb 91,468 users
100%, 1,468 of 1,468 users
47.1%, 691 of 1,468 users
34.4%, 505 of 1,468 users
30.9%, 453 of 1,468 users
26.4%, 387 of 1,468 users
22.8%, 335 of 1,468 users
22.9%, 336 of 1,468 users
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Feb 161,610 users
100%, 1,610 of 1,610 users
46.0%, 741 of 1,610 users
36.3%, 584 of 1,610 users
29.7%, 478 of 1,610 users
28.1%, 453 of 1,610 users
24.7%, 397 of 1,610 users
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Feb 231,575 users
100%, 1,575 of 1,575 users
47.9%, 754 of 1,575 users
35.2%, 554 of 1,575 users
31.6%, 497 of 1,575 users
27.0%, 425 of 1,575 users
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Mar 21,702 users
100%, 1,702 of 1,702 users
49.8%, 848 of 1,702 users
37.0%, 630 of 1,702 users
30.4%, 517 of 1,702 users
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Mar 91,655 users
100%, 1,655 of 1,655 users
48.7%, 806 of 1,655 users
38.9%, 644 of 1,655 users
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Mar 161,748 users
100%, 1,748 of 1,748 users
50.6%, 884 of 1,748 users
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Mar 231,820 users
100%, 1,820 of 1,820 users
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached

Use the arrow keys to move between cells; Home and End jump along a row, Ctrl+Home and Ctrl+End to the corners.

Monthly cohorts from ratios, sticky headers

valuesAre="ratios" takes retention shares (0–1) straight from your warehouse. maxHeight makes the table scroll inside its card: the header row and the cohort column stay put. steps={5} classes the colors; labels.period names the columns.

Monthly retention

Paid plans, Jul 2025 to Mar 2026, by cohort

CohortM0M1M2M3M4M5M6M7M8
Jul 20258,420 users
100%, 8,420 of 8,420 users
36.6%, 3,082 of 8,420 users
29.0%, 2,442 of 8,420 users
25.1%, 2,113 of 8,420 users
22.5%, 1,895 of 8,420 users
22.1%, 1,861 of 8,420 users
20.5%, 1,726 of 8,420 users
19.1%, 1,608 of 8,420 users
17.9%, 1,507 of 8,420 users
Aug 20259,105 users
100%, 9,105 of 9,105 users
36.6%, 3,332 of 9,105 users
30.6%, 2,786 of 9,105 users
26.6%, 2,422 of 9,105 users
23.9%, 2,176 of 9,105 users
21.9%, 1,994 of 9,105 users
21.9%, 1,994 of 9,105 users
20.5%, 1,867 of 9,105 users
Not yet reached
Sep 20258,830 users
100%, 8,830 of 8,830 users
38.2%, 3,373 of 8,830 users
30.5%, 2,693 of 8,830 users
28.1%, 2,481 of 8,830 users
25.4%, 2,243 of 8,830 users
23.3%, 2,057 of 8,830 users
21.7%, 1,916 of 8,830 users
Not yet reached
Not yet reached
Oct 20259,640 users
100%, 9,640 of 9,640 users
39.8%, 3,837 of 9,640 users
32.1%, 3,094 of 9,640 users
28.0%, 2,699 of 9,640 users
26.9%, 2,593 of 9,640 users
24.8%, 2,391 of 9,640 users
Not yet reached
Not yet reached
Not yet reached
Nov 202511.3K users
100%, 11.3K of 11.3K users
41.4%, 4,658 of 11.3K users
33.6%, 3,780 of 11.3K users
29.5%, 3,319 of 11.3K users
26.8%, 3,015 of 11.3K users
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Dec 202510.4K users
100%, 10.4K of 10.4K users
41.4%, 4,297 of 10.4K users
35.2%, 3,654 of 10.4K users
31.1%, 3,228 of 10.4K users
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Jan 202612K users
100%, 12K of 12K users
43.0%, 5,164 of 12K users
35.2%, 4,228 of 12K users
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Feb 202611.6K users
100%, 11.6K of 11.6K users
44.6%, 5,191 of 11.6K users
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Mar 202612.9K users
100%, 12.9K of 12.9K users
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached
Not yet reached

Use the arrow keys to move between cells; Home and End jump along a row, Ctrl+Home and Ctrl+End to the corners.

Files to copy

14 folders · 28 files · 4 packages
From theme/src/
  • components/charts/{cohort-chart.tsx, chart-export-menu.tsx, chart-export.ts, chart-figure.tsx, chart-fit.tsx, chart-icons.tsx, chart-parts.tsx, chart-patterns.tsx, chart-tip.tsx, chart-utils.ts, heatmap.tsx}
  • components/charts/chart-parts/
  • components/charts/cohort-chart/
  • components/charts/heatmap/
  • components/drawer/parts/sheet.tsx
  • components/kbd/
  • components/menu/
  • components/segmented/
  • components/skeleton/
  • components/status-icons/
  • hooks/{use-controllable.ts, use-direction.ts, use-intersection.ts, use-latest.ts, use-media-query.ts, use-preferences.ts}
  • motion/tokens.ts
  • lib/{cn.ts, csv.ts, form.ts, glide-highlight.tsx, heading.ts, math.ts, popup-a11y.ts, popup-motion.ts, warn-once.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/cohort-chart.jsonRegistry item: cohort-chart. The styles need the Tailwind v4 glass UI setup.
The examples also use
  • components/number-ticker/
  • lib/canvas-effects.ts
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/number-ticker.json
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Next.js: samples here pass functions (formatters, seriesLegend, a dashboard's load), so put them in a file that starts with "use client".

Props

PropTypeDefaultDescription
data (required)readonly CohortRow[]NoneTakes one row per cohort, oldest first.
valuesAre"counts" | "ratios""counts"How values are given: user counts (default) or retention ratios 0–1.
periodsnumberthe longest rowSets the number of period columns.
viewCohortViewNoneShow retention as percentages or user counts (controlled).
defaultViewCohortView"percent"Sets the starting view when uncontrolled.
onViewChange((view: CohortView) => void)NoneCalled when the person switches between the percent and count views.
viewTogglebooleantrueShow the % / users switch.
averagebooleantrueAdd a weighted-average row on top.
colorChartColor1Hue of the sequential scale: a palette slot 1–8.
domain[number, number]the lowest to the highest retention after period 0Retention range of the colour scale (0–1).
stepsnumber0Classes on the colour scale (e.g. 5); 0 = continuous.
maxHeightnumberNoneTallest the table gets before it scrolls inside (its header row stays put).
format((n: number) => string)compact numbers in localeFormats a cohort count for the cell labels, tooltips and data table: takes the number, returns the text shown.
formatPercent((ratio: number) => string)percentages, one decimalFormats ratios: percentages with one decimal in locale ("41.2%"; period 0 reads "100%").
localestring"en"Locale of the default formats.
legendbooleantrueShow the colour key.
onCellClick((cell: CohortCell) => void)NoneCalled with a cell on click, Enter or Space.
emptyStateReactNodeNoneShown when there is nothing to show.
labelsPartial<CohortChartLabels>defaultCohortChartLabelsEvery other string, for translation: labels={{ period: "…" }}; omitted keys keep the English of defaultCohortChartLabels. All 14 keys of CohortChartLabels are listed in the key table under the props table.
aria-label (required)stringNoneAccessible name of the chart; describe what it shows.
CohortChartLabels keys and English defaults (14)
Pass any key in labels; the rest keep the defaults of defaultCohortChartLabels.
KeyEnglish default
period(i) => `Week ${i}`
cohortCohort
size(n) => `${n} users`
averageAverage
averageNoteAll cohorts, weighted
percent%
countUsers
viewLabelShow retention as
retentionRetention
notYetNot yet reached
retained(count, size) => `${count} of ${size} users`
vsAverage(delta, direction) => (direction === "same" ? "Same as average" : `${delta} pts ${direction} average`)
instructionsUse the arrow keys to move between cells; Home and End jump along a row, Ctrl+Home and Ctrl+End to the corners.
hintTap a cell for details

CohortTable props

PropTypeDefaultDescription
data (required)readonly CohortRow[]NoneTakes one row per cohort, oldest first.
format((n: number) => string)compact numbers in localeFormats a cohort count for the cell labels, tooltips and data table: takes the number, returns the text shown.
labelsPartial<CohortChartLabels>defaultCohortChartLabelsEvery other string, for translation: labels={{ period: "…" }}; omitted keys keep the English of defaultCohortChartLabels. All 14 keys of CohortChartLabels are listed in the key table under the props table.
localestring"en"Locale of the default formats.
formatPercent((ratio: number) => string)percentages, one decimalFormats ratios: percentages with one decimal in locale ("41.2%"; period 0 reads "100%").
averagebooleantrueAdd a weighted-average row on top.
valuesAre"counts" | "ratios""counts"How values are given: user counts (default) or retention ratios 0–1.
periodsnumberthe longest rowSets the number of period columns.
captionstringNoneSets a visually hidden caption that names the table.
emptyStateReactNodeNoneShown when there are no rows.

Keyboard

KeysAction
TabMove into the grid (one stop, on the last cell you read).
←/→/↑/↓Move between cells (mirrored on right-to-left pages).
Home/EndFirst / last reached period of the row.
Ctrl+Home/Ctrl+EndFirst / last cell of the grid.
Page Up/Page DownTop / bottom row of the column.
Enter/SpaceCall onCellClick for the cell.
EscapeHide the tooltip.

Accessibility

  • A real table with role=“grid”: screen readers hear the cohort and the period with every cell, plus the other measure (“41.2%, 529 of 1,284 users”).
  • Cells not reached yet stay blank and read “Not yet reached”, never 0%.
  • Text inside each cell is black or white, whichever contrasts more with its fill (at least 4.5:1).
  • The view switch is a toggle group; the change is visible in every cell and in the grid's reading.
  • Touch: rows are 44px tall, a tap pins the tooltip; on narrow screens it docks above the grid.

All exports on this page

  • CohortChart — Retention cohort table: one row per cohort, one column per period since it started.
  • CohortTable — Every cohort as plain text: size, then "41.2% (529)" per period.
  • cohortModel — Ratios and counts for every cohort, plus the weighted average of each period.
  • cohortPercent — Retention as a percentage with one fixed decimal ("18.0%", never "18%" beside "18.5%"), so a column of them lines up.
  • defaultCohortChartLabels — The built-in English strings of CohortChart; spread it into your own labels and change what you need.

When to use the cohort retention chart

  • Use it as a retention heatmap (a cohort analysis table) where each row is a signup month and each column is periods since signup, with the cell color showing the share of the cohort still active.
  • Use it to judge whether a product change helped: the weighted-average row on top gives a baseline, and each cell tooltip compares its retention with that average.
  • Show user counts as well as percentages with the built-in switch, since the color always follows retention and cohorts of different sizes stay comparable.
  • Skip it when you track one population over time, where a Line chart of a single retention curve is clearer, or when the rows are not cohorts, where a Heatmap is the generic grid.
  • Pair it with ChartCard for the title and export, a Select to change the cohort granularity, and onCellClick to open a user list for the clicked cell in a Drawer or Dialog.

Frequently asked questions

48 charts pages in all: browse them on Charts.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .