Skip to content
Sign upPro
DataCohort tableMenu

Cohort table (Pro)

ProIncluded in $99

Retention by cohort as a shaded triangle, a weighted average, and the curve of the cohort you point at drawn against the average.

ProNine weekly cohorts. Point at Feb 9, after the onboarding redesign, to see it hold above the average.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/cohort-table

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

tsx
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

ProPeople instead of percent on another color, and a narrow frame where the periods scroll.

Props

PropTypeNotes
cohortsCohort[]{ label, size, values }; values are shares from 0 to 1
palettenumberPalette color for the shading. Default 1
defaultMetric"percent" | "count"What the cells show first
localestringNumber formatting
labelsPartial<CohortTableLabels>Title, period names and every other string

Keyboard

KeyAction
TabThe first cell; one tab stop for the grid
Arrow keysMove 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.