Ballmac UI home

Retention 1: cohort heatmap

A cohort retention table as a heatmap: rows of people who started together, columns of later periods, each cell tinted by the share still active, with headline numbers, percent or people, a keyboard grid and a size-weighted average row.

State

The normal view. Pick a state to see what the block shows while it loads, is empty or fails.

Open in v0 (opens in a new tab)

Installation

$ pnpm dlx shadcn@latest add @ballmac/retention-1

Usage

Example: retention-1-demo.tsx
"use client"

import { Retention1 } from "@/components/ballmac/blocks/retention-1/retention-1"

export default function Retention1Demo() {
  return <Retention1 />
}

States

Pass state and the block does the rest: skeletons that match its layout, a clear empty message, an error you can retry, and announcements for screen readers.

  • Loading

    Skeleton stat cards and table under the real heading, announced as loading.

    state="loading"
  • No cohorts yet

    Says retention appears once people have started and a full period has passed; emptyState sets the copy.

    state="empty" (or cohorts={[]})
  • Could not load

    An alert with Try again (onRetry).

    state="error"

Quality scorecard

7/7

Every applicable check passes

Measured in Chromium 153.0.8010.12 on October 19, 2026, on version 1.0.0, across 5 examples.

How we measure
  • Passed: Accessibility scan

    No serious or critical issues in light and dark, on a phone and a desktop (axe-core 4.13.0, WCAG 2.1 AA and best-practice rules).

  • Passed: Small screens

    No sideways scrolling at 360, 390 or 1280 px wide.

  • Passed: Reduced motion

    Every endless animation stops when the visitor asks for less motion.

  • Not applicable: Right to left

    Not mirrored by design: The cohort grid runs from the first period to the latest left to right in every language, like a chart, and makes up most of the page's elements.

  • Passed: Clean console

    No console errors or React hydration errors while loading.

  • Passed: Keyboard

    5 tab stops, each showing a visible change when it takes focus. 3 documented keys.

  • Passed: Loading, empty and error

    Ships loading, empty, error states, each with an example.

  • Passed: Automated tests

    Covered by retention-1.test.tsx.

  • For information: Footprint

    4.3 KB of source (gzip) in 1 file. Installs lucide-react.

Automated checks find a subset of problems and do not replace testing with a screen reader and a keyboard in your own app. What they miss.

Dependencies

Use with AI

A cohort retention heatmap. <Retention1 cohorts={[{ id, label: 'Week of 3 August', size: 1420, retention: [100, 64, 51, ...] }]} period='Week' locale />. retention is the percent still active in each period starting at period 0; newer cohorts have fewer entries. The average row weights each period by cohort size and only counts cohorts old enough to reach it. Headline numbers (period 1, period 4, trend) are worked out from the table. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Retention 1: cohort heatmap (@ballmac/retention-1) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Product analytics: do people come back?
  • Comparing the quality of signups week by week

Not for

  • A step-by-step conversion path (use funnel-1)
  • A trend line of one metric (use a chart)

Registry JSON: https://ui.ballmac.com/r/retention-1.json

Free to use in personal and commercial projects.

Ballmac UI Pro

Need the whole screen, not one piece?

150 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.

Not ready? Try three Pro blocks free

Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.