OfferLifetime Pro for $99

Cohort Retention

One row per signup cohort, one column per week or month, shaded on a fixed 0–100% scale with the number in every cell. Periods not reached are left empty, not zero, and the average row is weighted by cohort size. Switch percent or people.

The decision inside it

It is a table, not a picture

Every cell is text with the cohort and period as headers, so a screen reader reads the grid in order and the shade is only a help.

When to use it

Use Cohort Retention for signup cohorts by week or month as a triangle table shaded by % retained, with a size-weighted average row. Pass counts, not percentages.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Layro's Cohort Retention for this.
Install it: npx shadcn@latest add @layro/cohort-retention
(the @layro registry is set up in components.json, with LAYRO_KEY in .env.local)
Import it from @/components/ui/cohort-retention.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @layro registry with your CLI token: see the Namespaced tab.

Usage

components/retention.tsx
"use client";

import * as React from "react";
import { CohortRetention, type Cohort } from "@/components/ui/cohort-retention";

export function Retention({ weekly, monthly }: { weekly: Cohort[]; monthly: Cohort[] }) {
  const [period, setPeriod] = React.useState<"week" | "month">("week");
  return (
    <CohortRetention
      cohorts={period === "week" ? weekly : monthly}
      period={period}
      onPeriodChange={setPeriod}
      description="Retention of new workspaces by cohort"
    />
  );
}

API reference

“Copy prompt” above puts a full brief on your clipboard — install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

PropTypeNotes
cohortsrequiredCohort[]—
period"week" | "month"Names the columns: "Week 1" or "Month 1". Default "week".
onPeriodChange(p: "week" | "month") => voidShow the Weekly / Monthly switch; you swap the data.
show"percent" | "count"Default "percent".
showTogglebooleanShow the Percent / People switch. Default true.
descriptionrequiredstringAccessible caption.
loadingboolean—
errorReact.ReactNode—
onRetry() => void—
classNamestring—

Dependencies

npm packages

clsxtailwind-merge

Layro foundations, installed alongside it

layro-themechartsegmented-control

States

All of them are drawn by the component. None is left for you to design.

  • Weekly
  • Monthly
  • People
  • Loading
  • Empty
  • Error

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances

Lifetime access

Every component, and everything we ship next.

  • All 232 components, source included
  • Every template, and everything released after you buy
  • shadcn CLI or download — React 18/19, Tailwind v4
  • One payment. No subscription.