Cohort table (Pro)
ProIncluded in $99Retention by cohort as a shaded triangle, a weighted average, and the curve of the cohort you point at drawn against the average.
On this page
Installation
Needs chatcn Pro
This command works with a Pro license, along with every Pro component.
Or start free: sign up and get three Pro components on us, with a new one every month.
Usage
import { CohortTable } from "@/components/ui/chatcn/pro/cohort-table"
<CohortTable
cohorts={[
{ label: "Feb 9", size: 1245, values: [1, 0.69, 0.55, 0.46] }, // share still active per period
{ label: "Feb 16", size: 1382, values: [1, 0.7, 0.54] },
]}
labels={{ title: "Weekly retention, active users", period: (n) => `Week ${n}` }}
/>Each row is a cohort, each column a period after it started, and every cell is shaded on one palette color by how many are still active; periods that have not happened yet stay empty, so it reads as the familiar triangle. The last row is the average weighted by cohort size. Point at a cell, or walk the cells with the arrow keys, and that cohort's curve is drawn above the table against the average (dashed), with the numbers said in words, so a cohort that holds better or worse stands out at once. Switch between percent and people. On narrow screens the periods scroll while the cohort names stay.
Examples
States
Props
| Prop | Type | Notes |
|---|---|---|
cohorts | Cohort[] | { label, size, values }; values are shares from 0 to 1 |
palette | number | Palette color for the shading. Default 1 |
defaultMetric | "percent" | "count" | What the cells show first |
locale | string | Number formatting |
labels | Partial<CohortTableLabels> | Title, period names and every other string |
Keyboard
| Key | Action |
|---|---|
| Tab | The first cell; one tab stop for the grid |
| Arrow keys | Move between cells (reversed right to left) |
Accessibility
- A real table with row and column headers; every cell is a button named with the cohort, the period, the share and the people.
- The line above the table says the cohort's value against the average in words.
Motion
The cohort's curve fades in over 200 ms when it changes. Nothing else moves.