Retention 02

Retention-02 is a dashboard card that plots every signup cohort's retention curve as thin muted lines, highlights one cohort and the weighted average, and shows where the average levels off. It pairs the chart with headline stats, a legend, and a data table.

Retention 02
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

pnpm dlx shadcn@latest add @dashboardblocks/retention-02

Requires @dashboardblocks in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { Retention2 } from '@/components/dashboardblocks/retention/retention-02'<Retention2 cohorts={cohorts} description='Share of each monthly signup cohort still active' title='Retention curves' />
  • Comparing monthly or weekly signup cohorts to see whether newer cohorts retain better or worse than the average.
  • Showing a single cohort against the overall average while keeping the other cohorts visible as context.
  • Answering when retention flattens out, for example to decide on a retention window or churn-period metric.
  • Presenting retention curves in a product analytics or growth dashboard where a data table fallback is wanted.

Examples

Built-in sample data

Spread the bundled example props to render the component with realistic sample cohorts.

built-in-sample-data.tsx
import { Retention2, retention2ExampleProps } from '@/components/dashboardblocks/retention/retention-02'export default function Page() {  return <Retention2 {...retention2ExampleProps} />}

Weekly cohorts with a chosen highlight

Pass quarterly cohorts with their sizes and retained counts, label the period as Week, and highlight the first cohort.

weekly-cohorts-with-a-chosen-highlight.tsx
import { Retention2 } from '@/components/dashboardblocks/retention/retention-02'const cohorts = [  { label: 'Q1 2026', size: 900, retained: [900, 540, 470, 430] },  { label: 'Q2 2026', size: 1100, retained: [1100, 660, 590] },  { label: 'Q3 2026', size: 1250, retained: [1250, 700] },]export function WeeklyRetention() {  return (    <Retention2      cohorts={cohorts}      description='Share of each quarterly cohort still active, by weeks since signup'      highlight={0}      periodName='Week'      title='Weekly retention'    />  )}

Typed props with automatic highlight

Declare the props with the exported Retention2Props type and omit highlight so the component picks the newest cohort that has at least two periods.

typed-props-with-automatic-highlight.tsx
import {  Retention2,  type Retention2Props,} from '@/components/dashboardblocks/retention/retention-02'const props: Retention2Props = {  cohorts: [    { label: 'Jan 2026', size: 1184, retained: [1184, 712, 603, 541, 500] },    { label: 'Feb 2026', size: 1246, retained: [1246, 748, 634, 572] },    { label: 'Mar 2026', size: 1402, retained: [1402, 841, 716] },  ],  description: 'Share of each monthly signup cohort still active',  title: 'Retention curves',}export function Retention() {  return <Retention2 {...props} />}

API reference

PropTypeDefaultDescription
cohortsRetentionCohort[] (each item: { label: string; size: number; retained: number[] }), oldest first—Signup cohorts to plot. retained[0] is the cohort size and each later entry is the count still active in that period. The average is weighted by cohort size.
descriptionstring—Subtitle shown under the title in the card header. It is also used in the data table caption.
highlightnumberIndex of the newest cohort with at least two retained periods (falls back to 0)Index into cohorts of the cohort drawn as the highlighted chart-2 line and summarized in the first stat block.
periodNamestring'Month'Unit name used in axis ticks, tooltips, stat labels, and the table's first column. It is lowercased for inline text, for example 'month 4'.
titlestring—Card title text.

Accessibility

  • The full dataset is repeated in a data table with a caption built from the title, description, and a note that the average is weighted by cohort size, so screen reader users do not depend on the chart.
  • Series are distinguished by stroke width, opacity, and dashing (the average is dashed), not color alone; the legend lists each series with its swatch.
  • Stat blocks use dl, dt, and dd elements so each label is programmatically associated with its value.
  • The chart SVG is generated by Recharts without an explicit aria-label or role in this source, so rely on the table and text summaries for assistive technology.
  • Tooltips show only the average and highlighted cohort values, formatted as percentages with one decimal place.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Retention 02" component (dashboardblocks/retention-02) from its shadcn registry.1. Install it with: npx shadcn@latest add @dashboardblocks/retention-022. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: cohorts, description, highlight, periodName, title.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { Retention2 } from '@/components/dashboardblocks/retention/retention-02'<Retention2 cohorts={cohorts} description='Share of each monthly signup cohort still active' title='Retention curves' />```

Files & dependencies

  • registry/components/dashboardblocks/retention/retention-02.tsx→ @components/dashboardblocks/retention/retention-02.tsx
dependenciesrecharts
registryDependenciescardbuttonhttps://www.dashboardblocks.com/r/radix/block-state.jsonhttps://www.dashboardblocks.com/r/radix/chart-panel.jsonhttps://www.dashboardblocks.com/r/radix/kpi.jsonhttps://www.dashboardblocks.com/r/radix/link.jsonhttps://www.dashboardblocks.com/r/radix/retention.json

Looks similar, elsewhere