Retention Cohorts
1 バリエーションA 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>
);
}
インストール
API リファレンス
必須と記された props 以外はすべて省略できます。データ、文言、色はサンプルの内容が既定値です。
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.
boolean既定値
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
summary必須Stats for the selected metric.
RetentionSummarylabels必須Footer and legend copy.
Pick<RetentionCohortsLabels, "trend" | "averageFirst" | "best" | "trendUnit" | "legendLow" | "legendHigh">delaySeconds before the footer blur-rises in.
number既定値
0
RetentionCohortsHeader4 個の props
metrics必須Metrics shown as tabs.
RetentionMetric[]metric必須Id of the selected metric.
stringonMetricChange必須Called with the metric id a tab selects.
(metric: string) => voidlabels必須Title, description and tab aria label.
Pick<RetentionCohortsLabels, "title" | "description" | "metricsAriaLabel">
型5 個の型
これらの props が受け取るオブジェクト型とそのフィールド。
RetentionCohort3 個のフィールド
id必須Stable key for the cohort.
stringlabel必須Short cohort name, e.g. the signup week "Sep 29".
stringseries必須Series per metric id, e.g. `{ users: …, revenue: … }`.
Record<string, RetentionSeries>
RetentionMetric7 個のフィールド
id必須Key into each cohort's `series`.
stringlabel必須Tab label.
stringunitNoun after amounts in the tooltip, e.g. "users". Empty for currency.
stringcolor必須The single hue for this metric's cells. Any CSS color.
stringstrongTextClassName必須Text 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 個のフィールド
title必須Card title.
stringdescription必須One line under the title.
stringmetricsAriaLabel必須Accessible name of the metric tabs.
stringgridAriaLabel必須Accessible name of the grid.
stringcohortHeader必須Header over the cohort column.
stringaverageLabel必須Label of the average row.
stringaverageFirst必須Footer label for the average period-1 retention.
stringbest必須Footer label for the strongest cohort.
stringtrend必須Footer label for the change against the previous cohort.
stringtrendUnit必須Unit after the trend delta, e.g. "pts".
stringlegendLow必須Legend label at the weak end.
stringlegendHigh必須Legend label at the strong end.
string
RetentionSeries2 個のフィールド
base必須Starting amount in period 0 (signups, or revenue in that first week).
numbervalues必須Amount retained in period 0, 1, 2… Newer cohorts have fewer periods.
number[]
RetentionSummary3 個のフィールド
averageFirst必須Weighted average share kept in period 1, or null with no period-1 data.
number | nullbest必須Cohort with the highest period-1 share.
{ label: string; ratio: number } | nulltrend必須Newest period-1 share minus the one before it, in percentage points.
number | null