GooseUI

Components

Activity Heatmap

New

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

color-mix()

Mixes colors for activity levels.

Your browser:

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-heatmap
pnpm dlx shadcn@latest add @gooseui/activity-heatmap
yarn dlx shadcn@latest add @gooseui/activity-heatmap
bunx --bun shadcn@latest add @gooseui/activity-heatmap

Usage

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

PropTypeDefaultDescription
data{ date: string; count: number }[]-Days with values; repeated dates are summed
fromstring-First day. By default 364 days before to
tostring-Last day. By default the latest date in data, otherwise the render date
weekStartsOn0 | 1 | 2 | 3 | 4 | 5 | 60First day of the week, 0 is Sunday
localestring"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
cellSizenumber12Cell size in px
gapnumber3Gap between cells in px
showWeekdaysbooleantrueShow weekday labels
showMonthsbooleantrueShow month labels
showLegendbooleantrueShow 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
classNamestring-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