# Cohort table

Compare exact cohort percentages with separate missing and future states, a semantic desktop table, and compact phone summaries.

Access: pro. Category: Data. Kind: composite.

## When to use

- Use it when a page needs compare exact cohort percentages with separate missing and future states, a semantic desktop table, and compact phone summaries.
- Choose it when the data structure, labels, and state are supplied by the application and must remain consumer controlled.

## Alternatives

- Choose data-table instead when sortable column controls, native row selection and a scrollable table is the actual interface need, rather than cohort table.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Cohort table

```sh
npx shadcn@latest add @tidal-pro/cohort-table
```

Stylesheets: `components/ui/tidal.css`, `components/ui/cohort-table.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/cohort-table.css";
import{TidalCohortTable}from"./components/ui/cohort-table";
export default()=><div className="tidal-scope"><TidalCohortTable periods={[{id:"example",label:"Demo"}]} rows={[{id:"example",label:"Demo",population:1,reachedPeriods:1,values:{}}]} title={"Demo"}/></div>;
```

## Structured props

- `TidalCohortTable.periods: ReadonlyArray<TidalCohortPeriod>`: Required periods value accepted by this exported component.
- `TidalCohortTable.rows: ReadonlyArray<TidalCohortRow>`: Required rows value accepted by this exported component.
- `TidalCohortTable.title: ReactNode`: Required title value accepted by this exported component.
- `TidalCohortTable.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalCohortTable.formatPopulation?: ((value: number) => string) | undefined` (default String): Optional format population value accepted by this exported component.
- `TidalCohortTable.formatValue?: ((value: number) => string) | undefined` (default (v) => `${v}%`): Optional format value value accepted by this exported component.
- `TidalCohortTable.headingLevel?: "h2" | "h3" | "h4" | "h5" | "h6" | undefined` (default "h2"): Optional heading level value accepted by this exported component.
- `TidalCohortTable.labels?: Partial<{ cohort: string; population: string; missing: string; future: string; empty: string; invalid: string; table: string; }> | undefined` (default {}): Optional labels value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/cohort-table.tsx) | [Manifest](https://tidalui.com/examples/cohort-table.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { TidalCohortTable } from "./components/ui/cohort-table";

import "./components/ui/cohort-table.css";



const periods = Array.from({ length: 5 }, (_, i) => ({
  id: `week-${i}`,
  label: `Week ${i}`,
}));

const rows = [
  {
    id: "aug-24",
    label: "Aug 24",
    population: 428,
    reachedPeriods: 5,
    values: {
      "week-0": 100,
      "week-1": 72,
      "week-2": 61,
      "week-3": 54,
      "week-4": 49,
    },
  },
  {
    id: "aug-31",
    label: "Aug 31",
    population: 516,
    reachedPeriods: 4,
    values: { "week-0": 100, "week-1": 76, "week-2": 64, "week-3": 58 },
  },
  {
    id: "sep-7",
    label: "Sep 7",
    population: 483,
    reachedPeriods: 3,
    values: { "week-0": 100, "week-1": 74, "week-2": null },
  },
  {
    id: "sep-14",
    label: "Sep 14",
    population: 562,
    reachedPeriods: 2,
    values: { "week-0": 100, "week-1": 79 },
  },
  {
    id: "sep-21",
    label: "Sep 21",
    population: 608,
    reachedPeriods: 1,
    values: { "week-0": 100 },
  },
];

export function CohortTableDemo() {
  return (
    <div style={{ width: "100%", maxWidth: 1040 }}>
      <TidalCohortTable
        title="Weekly retention"
        description="Sample cohorts grouped by signup week. Percentages are supplied for each period."
        periods={periods}
        rows={rows}
      />
      <p style={{ fontSize: 11, textAlign: "center", color: "var(--t-muted)" }}>
        Fictional data. No data and Not reached represent different states.
      </p>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <CohortTableDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Consumer-owned unique period and row IDs/labels, up to12 periods and24 cohorts. Each row supplies a nonnegative safe-integer population, reachedPeriods count and keyed finite0..100 percentages or null. Missing values within reached periods mean No data; later periods mean Not reached and must not contain measurements. Invalid IDs, rates or future measurements fail visibly. Desktop semantic table has column/row headings, exact values beyond neutral shading and a locally bounded scroll region that enters tab order only when overflowing. Narrow containers switch to per-cohort description-list summaries. Formatters, localized labels, zero content, native section props/ref, h2-h6 hierarchy, RTL and forced colors are supported. The component does not calculate retention, populations, averages, forecasts or cohort membership, and performs no request or storage.
