Interactive example
Activity by periodSynthetic event counts
MorningAfternoonEveningMonTueWedThuFriMon, Morning. 14 events.Tue, Morning. 22 events.Wed, Morning. 17 events.Thu, Morning. 25 events.Fri, Morning. 19 events.Mon, Afternoon. 28 events.Tue, Afternoon. 35 events.Wed, Afternoon. No data.Thu, Afternoon. 31 events.Fri, Afternoon. 26 events.Mon, Evening. 9 events.Tue, Evening. 12 events.Wed, Evening. 15 events.Thu, Evening. 11 events.Fri, Evening. 18 events.
9 events35 eventsSlashed cells have no data
Use arrow keys to select a data point. Home selects the first point and End selects the last. Escape closes the value tooltip.
Mon, Morning
X
Mon
Y
Morning
Value
14 events
View data table 15 rows
Activity by period
Data pointXYValue
Mon, MorningMonMorning14 events
Tue, MorningTueMorning22 events
Wed, MorningWedMorning17 events
Thu, MorningThuMorning25 events
Fri, MorningFriMorning19 events
Mon, AfternoonMonAfternoon28 events
Tue, AfternoonTueAfternoon35 events
Wed, AfternoonWedAfternoonNo data
Thu, AfternoonThuAfternoon31 events
Fri, AfternoonFriAfternoon26 events
Mon, EveningMonEvening9 events
Tue, EveningTueEvening12 events
Wed, EveningWedEvening15 events
Thu, EveningThuEvening11 events
Fri, EveningFriEvening18 events

Installation

terminal
bunx --bun shadcn@latest add https://apple-ui-eduardo.vercel.app/r/heatmap.json

The 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

tsx
"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

PropertyTypeDefault
dataHeatmapDatum[]required
titlestringrequired
descriptionstringundefined
heightnumbercomponent default
loadingbooleanfalse
errorstringundefined
emptyMessagestringNo data to display.
showTablebooleantrue
compactbooleanfalse
valueFormatter(value: number) => stringlocalized number
classNamestringundefined
styleReact.CSSPropertiesundefined

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.
Read Apple’s guidance

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.