Heatmap
Scan a matrix for concentration, quiet periods, and repeated patterns.
- X
- Mon
- Y
- Morning
- Value
- 14 events
View data table 15 rows
| Data point | X | Y | Value |
|---|---|---|---|
| Mon, Morning | Mon | Morning | 14 events |
| Tue, Morning | Tue | Morning | 22 events |
| Wed, Morning | Wed | Morning | 17 events |
| Thu, Morning | Thu | Morning | 25 events |
| Fri, Morning | Fri | Morning | 19 events |
| Mon, Afternoon | Mon | Afternoon | 28 events |
| Tue, Afternoon | Tue | Afternoon | 35 events |
| Wed, Afternoon | Wed | Afternoon | No data |
| Thu, Afternoon | Thu | Afternoon | 31 events |
| Fri, Afternoon | Fri | Afternoon | 26 events |
| Mon, Evening | Mon | Evening | 9 events |
| Tue, Evening | Tue | Evening | 12 events |
| Wed, Evening | Wed | Evening | 15 events |
| Thu, Evening | Thu | Evening | 11 events |
| Fri, Evening | Fri | Evening | 18 events |
Installation
bunx --bun shadcn@latest add https://apple-ui-eduardo.vercel.app/r/heatmap.jsonThe registry includes the shared styles and dependencies. Import @/components/apple-ui/styles.css in your root layout once. For the package route, use the installation guide.
Usage
"use client";
import { Heatmap } from "@eduardoul/apple-ui";
const data = [
{ x: "Mon", y: "Morning", value: 14 },
{ x: "Tue", y: "Morning", value: 22 },
{ x: "Wed", y: "Morning", value: 17 },
{ x: "Mon", y: "Afternoon", value: 28 },
{ x: "Tue", y: "Afternoon", value: 35 },
{ x: "Wed", y: "Afternoon", value: null },
];
export function Example() {
return (
<Heatmap
title="Activity by period"
description="Synthetic event counts"
data={data}
valueFormatter={(value) => value + " events"}
/>
);
}Package imports use @eduardoul/apple-ui. Registry imports use @/components/apple-ui. Add "use client" to files that use state or event handlers.
API reference
| Property | Type | Default |
|---|---|---|
| data | HeatmapDatum[] | required |
| title | string | required |
| description | string | undefined |
| height | number | component default |
| loading | boolean | false |
| error | string | undefined |
| emptyMessage | string | No data to display. |
| showTable | boolean | true |
| compact | boolean | false |
| valueFormatter | (value: number) => string | localized number |
| className | string | undefined |
| style | React.CSSProperties | undefined |
Use className and style to customize the component. The package includes full TypeScript definitions for its supported element properties and refs.
Design guidance
- Use a heatmap when position on both axes defines a meaningful cell.
- Keep missing values visually distinct from zero. They describe different data states.
- Negative and zero values are valid. Each horizontal and vertical label pair must identify one unique cell.
- Provide the exact value through focus, touch, and the data table because color communicates only an estimate.
Accessibility
Give the chart a descriptive title and explain its units. Select a data point to read its values, or open the data table for the full dataset. Labels and values accompany color, and the chart adapts to reduced motion and appearance preferences. Test long labels, touch input and keyboard navigation with your own data.
Library styles support reduced motion, reduced transparency, increased contrast and forced colors. Read the accessibility foundation for the checks your application still needs.