PatternsPA-02
Cohort retention
How long people stay: one row per signup cohort, one column per period since, each cell the share still active.
- Part
- PA-02
- Component
- CohortRetentionCard
- From
- @lilt-ui/charts
Monthly retention
| Observation | Value |
|---|---|
| Feb 2026 · period M0 | 100% · 1.8K of 1.8K |
| Feb 2026 · period M1 | 46% · 846.4 of 1.8K |
| Feb 2026 · period M2 | 39.6% · 728.6 of 1.8K |
| Feb 2026 · period M3 | 34% · 625.6 of 1.8K |
| Feb 2026 · period M4 | 29.3% · 539.1 of 1.8K |
| Feb 2026 · period M5 | 25.2% · 463.7 of 1.8K |
| Feb 2026 · period M6 | 21.6% · 397.4 of 1.8K |
| Feb 2026 · period M7 | 18.6% · 342.2 of 1.8K |
| Mar 2026 · period M0 | 100% · 2.1K of 2.1K |
| Mar 2026 · period M1 | 48% · 1K of 2.1K |
| Mar 2026 · period M2 | 41.8% · 882 of 2.1K |
| Mar 2026 · period M3 | 36.3% · 765.9 of 2.1K |
| Mar 2026 · period M4 | 31.6% · 666.8 of 2.1K |
| Mar 2026 · period M5 | 27.5% · 580.3 of 2.1K |
| Mar 2026 · period M6 | 23.9% · 504.3 of 2.1K |
| Apr 2026 · period M0 | 100% · 2K of 2K |
| Apr 2026 · period M1 | 44% · 862.4 of 2K |
| Apr 2026 · period M2 | 37.4% · 733 of 2K |
| Apr 2026 · period M3 | 31.8% · 623.3 of 2K |
| Apr 2026 · period M4 | 27% · 529.2 of 2K |
| Apr 2026 · period M5 | 23% · 450.8 of 2K |
| May 2026 · period M0 | 100% · 2.5K of 2.5K |
| May 2026 · period M1 | 51% · 1.3K of 2.5K |
| May 2026 · period M2 | 44.9% · 1.1K of 2.5K |
| May 2026 · period M3 | 39.5% · 979.6 of 2.5K |
| May 2026 · period M4 | 34.8% · 863 of 2.5K |
| Jun 2026 · period M0 | 100% · 2.7K of 2.7K |
| Jun 2026 · period M1 | 53% · 1.4K of 2.7K |
| Jun 2026 · period M2 | 46.6% · 1.3K of 2.7K |
| Jun 2026 · period M3 | 41% · 1.1K of 2.7K |
| Jul 2026 · period M0 | 100% · 2.4K of 2.4K |
| Jul 2026 · period M1 | 55% · 1.3K of 2.4K |
| Jul 2026 · period M2 | 49% · 1.2K of 2.4K |
| Aug 2026 · period M0 | 100% · 3K of 3K |
| Aug 2026 · period M1 | 57% · 1.7K of 3K |
| Sep 2026 · period M0 | 100% · 3.1K of 3.1K |
| Average · period M0 | 100% · weighted by size, 8 cohorts |
| Average · period M1 | 51.2% · weighted by size, 7 cohorts |
| Average · period M2 | 43.7% · weighted by size, 6 cohorts |
| Average · period M3 | 37% · weighted by size, 5 cohorts |
| Average · period M4 | 31% · weighted by size, 4 cohorts |
| Average · period M5 | 25.3% · weighted by size, 3 cohorts |
| Average · period M6 | 22.8% · weighted by size, 2 cohorts |
| Average · period M7 | 18.6% · weighted by size, 1 cohort |
Installation
One package, one sheet.
Add the package, then import the component and the stylesheet once. See Getting started for theming.
npm install @lilt-ui/chartsimport { CohortRetentionCard } from '@lilt-ui/charts';
import '@lilt-ui/charts/styles.css';
Usage
The default card.
The default card above, as you would write it.
<CohortRetentionCard
title="Monthly retention"
data={cohorts}
cohort="cohort"
periods={['m0', 'm1', 'm2', 'm3']}
size="users"
/>
Omit title to leave out the visible title. Set header={false} to remove the whole header, and use aria-label to name a chart inside your own card. surface="ghost" controls only the visual frame. See Card composition.
Data
The shape it reads.
Later cohorts have lived through fewer periods, so their missing cells are left out and the grid steps down like a staircase. The average row weights each cohort by its size when size is given, and counts only cohorts that reached that period. Values must be shares from 0 to 1; anything else is an error rather than a misleading cell. Cohort names must be unique and keep your order.
// One row per cohort. Each period is the share still active, from 0 to 1;
// null is a period the cohort has not reached yet.
const cohorts = [
{ cohort: 'Feb 2026', users: 1840, m0: 1, m1: 0.46, m2: 0.4, m3: 0.34 },
{ cohort: 'Aug 2026', users: 2950, m0: 1, m1: 0.57, m2: null, m3: null },
];
Props35
Every prop.
Every prop CohortRetentionCard accepts, in the order you are likely to reach for them.
| Prop | Type | Description |
|---|---|---|
cohort | text key of Row | Each cohort’s name. |
periods | numeric key of Row[] | One field per period since the cohort started, each a share from 0 to 1. |
periodLabels | string[] | Column headings. Defaults to 0, 1, 2… |
size | numeric key of Row | Starting size: shown beside the name and used to weight the average. |
average | boolean | Add an average row under the cohorts. Defaults to true. |
headlinePeriod | key of periods | The period whose average is the headline. Defaults to the second. |
title | string | Optional visible title. Omit to render no title. Also supplies the accessible name unless aria-label is set. |
header | boolean | Defaults to true. False removes the whole header: title, headline, delta and period controls, with no reserved space. Pass data directly when your app owns period selection. |
aria-label | string | Accessible chart name, independent of the visible title. Falls back to title, then a generic chart name. |
data | Row[] | One row per observation. Omit when using ranges. |
height | number | Minimum plot height, default 260. Dense lanes expand to keep every mark visible. |
depth | boolean | Lit tiles, solid bars, or spheres. Data positions remain exact; loading keeps the same depth treatment. |
color | string | Override the palette with one CSS color. |
headline | number | Override the resting headline. |
delta | number | Fractional change shown alongside the headline. |
deltaTone | 'default' | 'inverse' | 'neutral' | Use inverse when a decrease is good. |
range | string | Static period label. |
ranges | { id, label, data, headline?, delta? }[] | Period choices with their own data. |
defaultRange | string | Initial period id. |
locale | string | Locale for numbers and dates; defaults to en-US. |
formatValue | (value: number) => string | Custom value formatter. |
badge | ReactNode | Content for the glass tab above the card. |
className | string | Class on the card frame. |
style | CSSProperties | ChartStyle | Inline styles and scoped chart variables. |
onSelectionChange | (selection | null) => void | Reports id, original row (or null for an absent day), value, and pinned state. |
renderReadout | (selection | null) => ReactNode | Consumer-owned readout, including when the header is hidden. |
valueFormat | Intl.NumberFormatOptions | Formats the headline, tiles, and axis, e.g. currency. |
surface | 'elevated' | 'outline' | 'ghost' | Card treatment. Ghost removes the visual frame only; header and legend are independent controls. |
palette | 'spectrum' | 'iris' | 'cobalt' | 'emerald' | Series colors. Spectrum by default; explicit series colors still win. |
numberStyle | 'count' | 'pop' | 'slide' | 'roll' | 'flow' | 'scramble' | How the headline animates when its value changes. Count (default) counts to the new value. |
loading | boolean | Shows a neutral loading skeleton, not data. |
loadingStyle | 'shimmer' | 'draw' | 'breathe' | Shimmer sweeps a highlight over still shapes; draw reveals them in order; breathe lets them settle. Follows the selected look, including depth, and respects reduced motion. |
empty | 'dots' | 'shape' | ReactElement | null | What the card shows when the period has no data. Dots (default) gathers a quiet dot field around the message; shape lays the chart’s own outline behind it. Pass `<ChartEmpty>` with your own words, any element of your own, or null for nothing. Both looks stay still, so empty never reads as loading, and the headline reads a dash, never zero. |
motion | 'auto' | 'none' | None turns off decorative motion; reduced motion does this automatically. |
onKeyDown | KeyboardEventHandler<HTMLElement> | Keyboard handler on the card frame. Chart inspection also has its own keyboard handling. |