# Cohort Retention

> Weekly retention as the classic triangle: a row per signup cohort, a column per week, each cell shaded by the share still active. Cells fill in a diagonal wave as the weeks unlock. Above, the chosen cohort's curve draws against the dashed average and morphs to each new cohort. Hovering a cell crosses its row and week and reads the users kept and the gap to average; cells switch between shares and user counts.

## Spec sheet

| | |
| --- | --- |
| Access | Free: no account, free for commercial use |
| Shelf | Blocks › Charts |
| Live preview | https://uibrik.com/components/cohort-retention |
| Writes | 1 file into `components/uibrik/cohort-retention/` |
| Packages | `motion` (the CLI installs them) |
| Needs | React 19, Tailwind CSS v4, a project set up with `npx shadcn@latest init` |
| Theme | Reads the shadcn tokens and follows class-based dark mode ([theming](https://uibrik.com/docs/theming.md)) |
| Updated | Nov 27, 2026 |

## Add it

```bash
npx shadcn@latest add https://uibrik.com/r/cohort-retention.json
```

With the `@uibrik` namespace in `components.json` ([setup](https://uibrik.com/docs/installation.md)): `npx shadcn@latest add @uibrik/cohort-retention`.

Can't run commands? https://uibrik.com/components/cohort-retention/prompt.txt has every file verbatim, with the setup steps, ready for an assistant to write.

## Render it

Renders as is; every value shown is the default, so delete any line you don't need.

```tsx
import { CohortRetention } from "@/components/uibrik/cohort-retention/cohort-retention";

<CohortRetention
  title="Retention"
  color="#12a594"
  display="percent"
  period="Week"
  width={620}
  // cohorts={[{ label: "…", users: 0, retention: [0] }]}
  // defaultCohort={0}
  // onCohortChange={(index) => {}}
/>
```

## Tune it

The same props as the Customize panel on https://uibrik.com/components/cohort-retention.

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| `title` | `string` | `"Retention"` | Heading above the grid. |
| `color` | `string` | `"#12a594"` | Hue the cells are shaded from. |
| `display` | `"percent" \| "users"` | `"percent"` | Show shares or user counts in the cells. |
| `period` | `string` | `"Week"` | Name of one period, for the column heads. |
| `width` | `number` | `620` | Width of the card; never wider than its container. |

## Wire it

The props the Customize panel doesn't show: ranges, data, content and callbacks.

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| `cohorts` | `{ label: string; users: number; retention: number[] }[]` |  | Oldest first. retention holds the share active in period 1, 2, 3…, shorter for younger cohorts. |
| `defaultCohort / onCohortChange` | `number / (index) => void` |  | Cohort drawn in the chart on mount, and a callback when another is picked. |
| `className` | `string` |  | Classes for the wrapper. |

## Where it fits

- **Product analytics dashboards**: One grid shows whether newer cohorts stick better than older ones, without a chart per cohort. Pairs with [Subscriber Funnel](https://uibrik.com/components/subscriber-funnel.md) (Pro) and [KPI Tile](https://uibrik.com/components/kpi-tile.md).
- **Growth and lifecycle reviews**: The gap to average on every cell says which launch or onboarding change moved retention. Pairs with [Revenue Dashboard](https://uibrik.com/components/revenue-dashboard.md) (Pro).
- **SaaS investor and board updates**: A triangle that fills in reads as momentum before anyone looks at the numbers.

## Same shelf: Charts

- [Flame Graph](https://uibrik.com/components/flame-graph.md) (Pro): A CPU profile as a flame graph: a row per call depth, each frame as wide as the time spent in it. Rows wipe in from the root down. Clicking a frame zooms it to the full width while its callers stay on top as crumbs, with no text stretching; hovering lights every call to the same function and reads its total and self time. Below, the functions with the most self time jump straight to their frame. App code takes the accent, libraries stay neutral and native code takes a second hue, all shaded by how hot they run.
- [Flow Chart](https://uibrik.com/components/flow-chart.md) (Pro): A Sankey of flows between columns: point at a node or ribbon to light its whole path while the rest recede.
- [Funnel](https://uibrik.com/components/funnel.md) (Pro): A conversion funnel whose drop-off between steps reads as a slope you can hover, with every step's share of the start.
- [Heatmap Rank](https://uibrik.com/components/heatmap-rank.md) (Pro): An activity heatmap that turns into a ranking, where each row's day cells slide together into one bar and the bars sort by total, and that drills down: a day cell opens into hour tiles, an hour opens into its commits.
- [Live Line](https://uibrik.com/components/live-line.md) (Pro): A realtime line that scrolls smoothly as samples stream in, and freezes under the pointer so you can read any moment.
- [Match Momentum](https://uibrik.com/components/match-momentum.md) (Pro): A live match card: score and clock on top, and a momentum wave that grows minute by minute, above the line when the home side presses and below when the away side does. Goals and cards are pinned to the wave at their minute and name the player on hover; running stats split home against away and ease to each new value.

## Ground rules

- Only the props above exist. To change anything else, edit the installed file.
- Keep the files in `components/uibrik/cohort-retention/` so the import paths keep resolving.
- The playbook for working with the whole library: https://uibrik.com/llms.txt
