|Kit

Calendar Heatmap

A GitHub-style activity grid — one square per day, a column per week, the shade saying how much happened. Keyboard grid, full day names for screen readers, any locale and time zone.

CalendarHeatmap shows anything counted per day over a long window: attendance, commits, exercises submitted. Hand it a list of { date, value } and it lays out the year ending today.

import { CalendarHeatmap } from '@42-central/ui-react/calendar-heatmap';

<CalendarHeatmap data={[{ date: new Date(), value: 3 }]} color="green" />

Entries on the same day add up, so a raw event list works as well as daily totals: events.map((e) => ({ date: e.createdAt, value: 1 })).

630 activities in the last year

Less01–34–78–1011+More

Code

<Card>
  <Card.Header>
    <Card.Title>{total} activities in the last year</Card.Title>
  </Card.Header>
  <Card.Content>
    <CalendarHeatmap data={data} color="brand" />
  </Card.Content>
</Card>

Like every chart in the kit, it belongs inside a Card: it has no surface of its own. The squares keep their size, whatever the container: when the weeks don't fit, they scroll sideways and open on the latest week, while the weekday labels stay pinned beside them. That is what makes it work on a phone, and at any range length.

Colors

The ramp is the palette's solid color at four strengths, so every color, custom palettes included, makes its own ramp. Without color it inherits the nearest data-color, like every colored component.

Less01–34–78–1011+More
Less01–34–78–1011+More
Less01–34–78–1011+More
Less01–34–78–1011+More

Code

<CalendarHeatmap data={data} color="green" />
<CalendarHeatmap data={data} color="blue" />
<CalendarHeatmap data={data} color="orange" />
<CalendarHeatmap data={data} color="neutral" />

Levels

By default the busiest day is split into quarters, the way GitHub does it. Pass thresholds to fix the levels yourself: each number is the lowest value of a level, so [1, 3, 6, 10] reads 1–2, 3–5, 6–9 and 10+. One to four of them, never more, since a reader can't rank more than four shades. With fewer, they spread across the ramp and the busiest level is always the full color.

Counts are whole numbers, so the default levels are too. Data on another scale (hours, a score) should pass its own thresholds.

Less01–910+More
Less01–23–56–910+More

Code

<CalendarHeatmap data={data} color="green" thresholds={[1, 10]} />
<CalendarHeatmap data={data} color="green" thresholds={[1, 3, 6, 10]} />

Range and week start

range sets the first and last day shown, both included. Weeks start on the locale's first day of the week; startOfWeek overrides it.

Less01–34–67–910+More

Code

<CalendarHeatmap
  data={data}
  range={{ start: new Date(2026, 7, 1), end: new Date(2026, 9, 31) }}
  startOfWeek="mon"
  color="blue"
/>

Long ranges

Any length works, since the weeks scroll rather than shrink. Here, three years:

Less01–34–78–1011+More

Code

<CalendarHeatmap
  data={data}
  range={{ start: threeYearsAgo, end: today }}
  color="green"
/>

Size

The squares follow Figma's 12px cell and 4px gap, set as the custom properties --cell and --gap. Override them from className to resize the whole heatmap, legend included.

Less01–34–78–1011+More
Less01–34–78–1011+More

Code

<CalendarHeatmap data={data} className="[--cell:0.5rem] [--gap:2px]" />
<CalendarHeatmap data={data} className="[--cell:1rem] [--gap:0.25rem]" />

Locale, time zone and direction

Dates, weekday and month names, and numbers all come from Intl in the resolved locale: the component's locale prop, else IntlProvider's. Each Date in data is counted on its day in the resolved timeZone, so an event at 23:30 in Paris lands on the Paris day, whatever the visitor's own zone.

The only words Intl can't produce are in translations. day is the sentence that names a day, written as one function so the translation keeps its own word order. Under an RTL locale the weeks run right to left and the arrow keys follow.

Moins01–34–78–1011+Plus
أقل٠١–٣٤–٧٨–١٠١١+أكثر

Code

<IntlProvider locale="fr-FR">
  <CalendarHeatmap
    data={data}
    translations={{
      label: 'Activité',
      day: ({ value, formattedValue, formattedDate }) =>
        value === 0
          ? `Aucune activité le ${formattedDate}`
          : `${formattedValue} activité${value > 1 ? 's' : ''} le ${formattedDate}`,
      less: 'Moins',
      more: 'Plus',
    }}
  />
</IntlProvider>

Clickable days

With onDayClick, days activate by click, Enter or Space, and the callback gets the day's midnight (in the heatmap's time zone) and its total.

Less01–34–78–1011+More

Click a day, or press Enter on one.

Code

<CalendarHeatmap
  data={data}
  onDayClick={(date, value) => setPicked({ date, value })}
/>

API

Prop

Type

Accessibility

  • A real role="grid", named by translations.label, with a single tab stop on the latest day. ←/→ move a week (mirrored in RTL), ↑/↓ a day, Home/End go along the row, Ctrl+Home/End to the first and last day, and PageUp/PageDown a month.
  • Every day names itself in full: "3 activities on Monday, October 26, 2026". Each row has a header with the full weekday name. The visible weekday and month labels are decorative, since each day already says its date.
  • Moving focus to a day scrolls it into view, with room for its focus ring.
  • One shared tooltip follows hover and focus, and Esc dismisses it. It repeats the focused day's name, so it is hidden from assistive technology rather than read twice.
  • Color is never the only channel: the exact value is in every day's name and tooltip, the legend is always shown with each level's range, and in forced-colors mode the level is drawn as a square that grows with it.

Changelog

v0.30.0
  • FilePreview's text pane and CalendarHeatmap's weeks scroll with the kit's scrollbars

    #494
  • Weekday labels stay in line with their rows when a scrollbar shows

    #494
v0.22.0
  • New CalendarHeatmap: a GitHub-style activity grid that sums { date, value } entries per day, shades them in up to four thresholds of any color, and scrolls a long range inside its container, opening on the latest week

    #431
  • Localized through Intl (dates, numbers, week start, RTL) with a translations prop, and navigable as a role="grid" with arrow keys, Home/End and PageUp/PageDown

    #431

On this page