# Heatmap

Inspect exact values across two categorical axes with keyboard navigation and a neutral intensity scale.

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

## When to use

- Use it when a page needs inspect exact values across two categorical axes with keyboard navigation and a neutral intensity scale.
- Choose it when the data structure, labels, and state are supplied by the application and must remain consumer controlled.

## Alternatives

- Choose analytics-card instead when explore revenue, compare periods and inspect chart values is the actual interface need, rather than heatmap.

## 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 Heatmap

```sh
npx shadcn@latest add @tidal-pro/heatmap
```

Stylesheets: `components/ui/tidal.css`, `components/ui/heatmap.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/heatmap.css";
import{TidalHeatmap}from"./components/ui/heatmap";
export default(p:Parameters<typeof TidalHeatmap>[0])=><div className="tidal-scope"><TidalHeatmap {...p}/></div>;
```

## Structured props

- `TidalHeatmap.cells: ReadonlyArray<TidalHeatmapCell>`: Required cells value accepted by this exported component.
- `TidalHeatmap.columns: ReadonlyArray<TidalHeatmapAxis>`: Required columns value accepted by this exported component.
- `TidalHeatmap.onSelectedCellChange: (cell: TidalHeatmapCell, event: MouseEvent<HTMLButtonElement>) => void`: Callback invoked when the selected cell change interaction is proposed.
- `TidalHeatmap.rows: ReadonlyArray<TidalHeatmapAxis>`: Required rows value accepted by this exported component.
- `TidalHeatmap.selectedCell: TidalHeatmapCoordinate | null`: Required selected cell value accepted by this exported component.
- `TidalHeatmap.title: ReactNode`: Required title value accepted by this exported component.
- `TidalHeatmap.cellProps?: ((cell: TidalHeatmapCell) => CellProps) | undefined`: Optional cell props value accepted by this exported component.
- `TidalHeatmap.cellRef?: ((cell: TidalHeatmapCell) => Ref<HTMLButtonElement>) | undefined`: Optional cell ref value accepted by this exported component.
- `TidalHeatmap.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalHeatmap.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalHeatmap.formatValue?: ((value: number) => string) | undefined` (default defaultFormat): Optional format value value accepted by this exported component.
- `TidalHeatmap.headingLevel?: "h2" | "h3" | "h4" | "h5" | undefined` (default "h2"): Optional heading level value accepted by this exported component.
- `TidalHeatmap.labels?: Partial<{ grid: string; noData: string; noneSelected: string; selection: string; range: string; minimum: string; maximum: string; invalid: string; empty: string; }> | undefined` (default {}): Optional labels value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/heatmap.tsx) | [Manifest](https://tidalui.com/examples/heatmap.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 { useState } from "react";

import { TidalHeatmap, type TidalHeatmapCoordinate } from "./components/ui/heatmap";

import "./components/ui/heatmap.css";



const rows = [
  { id: "mon", label: "Monday" },
  { id: "tue", label: "Tuesday" },
  { id: "wed", label: "Wednesday" },
  { id: "thu", label: "Thursday" },
  { id: "fri", label: "Friday" },
];

const columns = [
  { id: "9", label: "9 AM" },
  { id: "11", label: "11 AM" },
  { id: "13", label: "1 PM" },
  { id: "15", label: "3 PM" },
  { id: "17", label: "5 PM" },
];

const counts = [
  [42, 81, 123, 96, 35],
  [58, 102, 184, 128, 54],
  [74, 125, 246, 192, 79],
  [61, 118, 205, 151, 62],
  [36, 69, 97, 82, null],
];

const cells = rows.flatMap((row, r) =>
  columns.map((column, c) => ({
    rowId: row.id,
    columnId: column.id,
    value: counts[r]![c]!,
  })),
);

export function HeatmapDemo() {
  const [selected, setSelected] = useState<TidalHeatmapCoordinate | null>({
    rowId: "wed",
    columnId: "13",
  });
  return (
    <div style={{ width: "100%", maxWidth: 940, display: "grid", gap: 12 }}>
      <TidalHeatmap
        title="Workspace activity"
        description="Sample events by weekday and time. Select a cell for its exact count."
        rows={rows}
        columns={columns}
        cells={cells}
        selectedCell={selected}
        onSelectedCellChange={setSelected}
      />
      <p style={{ margin: 0, fontSize: 11, color: "var(--t-muted)" }}>
        Fictional counts. Arrow keys move through cells; Enter selects. Missing
        data stays distinct from zero.
      </p>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <HeatmapDemo />
    </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}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation."],"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 rows and columns require unique nonblank string IDs and labels. Cells identify one exact row/column pair and contain a finite number or null; omitted pairs also mean no data. Duplicate cells, unknown axes, invalid selection or values, axes beyond100 entries, or matrices beyond2500 cells produce a visible error. Controlled selectedCell/onSelectedCellChange proposes the exact cell through native activation. Independent roving keyboard focus supports Arrow keys, Home/End and Ctrl+Home/End; logical horizontal arrows honor RTL and reveal only the local matrix scroller. Exact cell values remain visible and accessible beyond color, missing data stays distinct from zero, and the default formatter preserves represented number precision. The intensity calculation scales before subtracting to handle extreme finite domains. Root/cell native props and cleanup-aware refs are supported with owned markup, disabled state, tab order and labels protected. Optional formatting, labels, h2-h5 hierarchy and global disabled state are supported. No aggregation, request, analytics, storage or external effect is performed. Stable per-cell ref identities avoid remounts on ordinary focus/selection updates. A removed focused grid falls back to the labelled root only while focus remains on body. Composition events, including keyCode229 fallback, do not move cells.
