Retention Cohorts
1 variantA cohort retention grid for analytics apps, with a crosshair tooltip, keyboard navigation, and users and revenue views.
Cohort grid
A weekly cohort retention grid with a diagonal blur-rise entrance, a row-and-column crosshair tooltip, and arrow-key navigation. Users and Revenue tabs crossfade every cell's shade, and a footer line sums up week-1 retention, the best cohort, and the latest trend.
Retention
Weekly signup cohorts, last 8 weeks
| Cohort | W0 | W1 | W2 | W3 | W4 | W5 | W6 | W7 |
|---|---|---|---|---|---|---|---|---|
| Sep 291,240 | ||||||||
| Oct 61,385 | ||||||||
| Oct 131,162 | ||||||||
| Oct 201,508 | ||||||||
| Oct 271,620 | ||||||||
| Nov 31,447 | ||||||||
| Nov 101,712 | ||||||||
| Nov 171,834 | ||||||||
| All cohorts |
Avg W145.2%BestNov 1050.0%Latest vs prev+5.0pts
"use client";
import { RetentionCohorts } from "@/components/premium/retention-cohorts";
export function RetentionCohortsGridPreview() {
return (
<div className="w-full px-4 py-10">
<RetentionCohorts />
</div>
);
}
Source code is locked
Get access to install premium components and view the full source.
Open dashboardInstall
API Reference
Every prop is optional unless marked required. Data, copy, and colors default to the sample content.
RetentionCohorts12 props
cohortsCohorts from oldest (top) to newest (bottom), each with a series per metric.
RetentionCohort[]metricsMetrics the tabs switch between, with their hue and formatting.
RetentionMetric[]metricControlled metric id.
stringdefaultMetricInitial metric id when uncontrolled. Defaults to the first metric.
stringonMetricChangeCalled with the metric id a tab selects.
((metric: string) => void)periodsNumber of period columns. Defaults to the oldest cohort's length.
numberperiodLabelShort column header for a period index. Defaults to `W0`, `W1`…
((index: number) => string)periodNameLong period name for the tooltip and aria labels. Defaults to `Week 0`…
((index: number) => string)showAverageShow the "All cohorts" weighted average row.
booleanDefault
trueonActiveCellChangeCalled when hover, focus or tap changes the active cell.
((cell: CohortGridCell | null) => void)labelsCopy overrides; anything omitted keeps the default.
Partial<RetentionCohortsLabels>classNameClasses for the card.
string
RetentionCohortsFooter3 props
summaryRequiredStats for the selected metric.
RetentionSummarylabelsRequiredFooter and legend copy.
Pick<RetentionCohortsLabels, "trend" | "averageFirst" | "best" | "trendUnit" | "legendLow" | "legendHigh">delaySeconds before the footer blur-rises in.
numberDefault
0
RetentionCohortsHeader4 props
metricsRequiredMetrics shown as tabs.
RetentionMetric[]metricRequiredId of the selected metric.
stringonMetricChangeRequiredCalled with the metric id a tab selects.
(metric: string) => voidlabelsRequiredTitle, description and tab aria label.
Pick<RetentionCohortsLabels, "title" | "description" | "metricsAriaLabel">
Types5 types
The object types these props take, field by field.
RetentionCohort3 fields
idRequiredStable key for the cohort.
stringlabelRequiredShort cohort name, e.g. the signup week "Sep 29".
stringseriesRequiredSeries per metric id, e.g. `{ users: …, revenue: … }`.
Record<string, RetentionSeries>
RetentionMetric7 fields
idRequiredKey into each cohort's `series`.
stringlabelRequiredTab label.
stringunitNoun after amounts in the tooltip, e.g. "users". Empty for currency.
stringcolorRequiredThe single hue for this metric's cells. Any CSS color.
stringstrongTextClassNameRequiredText class for strong cells, dark enough to read on the full hue.
stringmaxRatioShare at which a cell reaches full strength. Defaults to 1.
numberformatValueFormats an absolute amount for this metric.
(value: number) => string
RetentionCohortsLabels12 fields
titleRequiredCard title.
stringdescriptionRequiredOne line under the title.
stringmetricsAriaLabelRequiredAccessible name of the metric tabs.
stringgridAriaLabelRequiredAccessible name of the grid.
stringcohortHeaderRequiredHeader over the cohort column.
stringaverageLabelRequiredLabel of the average row.
stringaverageFirstRequiredFooter label for the average period-1 retention.
stringbestRequiredFooter label for the strongest cohort.
stringtrendRequiredFooter label for the change against the previous cohort.
stringtrendUnitRequiredUnit after the trend delta, e.g. "pts".
stringlegendLowRequiredLegend label at the weak end.
stringlegendHighRequiredLegend label at the strong end.
string
RetentionSeries2 fields
baseRequiredStarting amount in period 0 (signups, or revenue in that first week).
numbervaluesRequiredAmount retained in period 0, 1, 2… Newer cohorts have fewer periods.
number[]
RetentionSummary3 fields
averageFirstRequiredWeighted average share kept in period 1, or null with no period-1 data.
number | nullbestRequiredCohort with the highest period-1 share.
{ label: string; ratio: number } | nulltrendRequiredNewest period-1 share minus the one before it, in percentage points.
number | null