A grid of days for a chosen range: one column per week, five intensity levels, month and weekday labels from Intl. The server computes the whole grid, tooltips show on hover and focus through CSS. A small client part only moves focus with the arrow keys and calls onCellClick.
Browser Support
Mixes colors for activity levels.
Preview
Hover a day to see its value, or press Tab and move with the arrows: left and right jump a week, up and down a day.
1,018 activities in the last year
Installation
npx shadcn@latest add @gooseui/activity-heatmappnpm dlx shadcn@latest add @gooseui/activity-heatmapyarn dlx shadcn@latest add @gooseui/activity-heatmapbunx --bun shadcn@latest add @gooseui/activity-heatmapUsage
import { ActivityHeatmap } from "@/components/ui/activity-heatmap"
const data = [
{ date: "2026-11-20", count: 4 },
{ date: "2026-11-21", count: 9 },
{ date: "2026-11-22", count: 1 },
]
export default function Example() {
return <ActivityHeatmap data={data} to="2026-11-22" />
}Examples
Week from Monday, custom range
weekStartsOn moves the first row, from and to cut the range, and onCellClick makes days clickable (Enter and Space work too). onCellClick is a function, so this example renders the heatmap from a client component.
Workouts
<ActivityHeatmap
data={workouts}
from="2026-06-01"
to="2026-08-31"
weekStartsOn={1}
cellSize={16}
gap={4}
locale="de-DE"
labels={{
cell: (count, date) => (count === 0 ? `Rest day, ${date}` : `${count} min, ${date}`),
}}
onCellClick={(day) => console.log(day.date, day.count)}
/>Own levels
By default the levels are quarters of the largest value. getLevel sets fixed steps instead.
<ActivityHeatmap
data={data}
from="2026-05-25"
to="2026-11-22"
showWeekdays={false}
getLevel={(count) => (count === 0 ? 0 : count < 3 ? 1 : count < 6 ? 2 : count < 9 ? 3 : 4)}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| data | { date: string; count: number }[] | - | Days with values; repeated dates are summed |
| from | string | - | First day. By default 364 days before to |
| to | string | - | Last day. By default the latest date in data, otherwise the render date |
| weekStartsOn | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 0 | First day of the week, 0 is Sunday |
| locale | string | "en-US" | Locale for months, weekdays and dates |
| getLevel | (count: number, max: number) => 0 | 1 | 2 | 3 | 4 | - | Maps a value to a level 0–4 |
| cellSize | number | 12 | Cell size in px |
| gap | number | 3 | Gap between cells in px |
| showWeekdays | boolean | true | Show weekday labels |
| showMonths | boolean | true | Show month labels |
| showLegend | boolean | true | Show the legend |
| labels | { less?; more?; grid?; cell?: (count, date) => string } | - | Legend texts, grid name and cell text |
| onCellClick | (day: { date: string; count: number }) => void | - | Called on click, Enter or Space. Pass it from a client component |
| className | string | - | Additional CSS classes |
Features
- Server rendering: the grid and tooltips are HTML and CSS, the client part is under 1 kB
- Intl labels: months, weekdays and dates follow the locale prop
- Theme colors: levels mix --primary into the background, so any theme works
- Keyboard: an ARIA grid with one tab stop; arrows, Home, End, PageUp and PageDown
- UTC dates: without to and data the range ends on the render date of the server