Skip to content

Calendar Heatmap for React

A React calendar heatmap that draws a GitHub-style contribution graph: one cell per day on sequential color steps. Pass data as readonly CalendarDatum[]: one entry per day: { date: "2026-03-04", value: 12 }.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/calendar-heatmap.json

Contributions

Use the arrow keys to move by day or week; Page Up and Page Down move by month.

  • CalendarHeatmap
  • CalendarHeatmapTable
  • isoDate
  • toDayNumber
  • localeWeekStart
  • +6 more
  • +3 more

Contributions in a year

Switch the year to see the days cross-fade to their new levels. Days after today are outlined, never painted as zero. On a phone the weeks scroll sideways inside the card (the weekday names stay put), opening on the latest week. Arrow keys move by day and week, Page Up / Page Down by month.

Contributions

2026, en-US

1,116 in total

Files to copy

12 folders · 27 files · 4 packages
From theme/src/
  • components/charts/{calendar-heatmap.tsx, chart-export-menu.tsx, chart-export.ts, chart-figure.tsx, chart-fit.tsx, chart-icons.tsx, chart-parts.tsx, chart-patterns.tsx, chart-tip.tsx, chart-utils.ts, heatmap.tsx}
  • components/charts/chart-parts/
  • components/charts/heatmap/
  • components/drawer/parts/sheet.tsx
  • components/kbd/
  • components/menu/
  • components/skeleton/
  • components/status-icons/
  • hooks/{use-controllable.ts, use-intersection.ts, use-latest.ts, use-media-query.ts, use-preferences.ts}
  • motion/tokens.ts
  • lib/{cn.ts, csv.ts, form.ts, glide-highlight.tsx, heading.ts, math.ts, popup-a11y.ts, popup-motion.ts, warn-once.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/calendar-heatmap.jsonRegistry item: calendar-heatmap. The styles need the Tailwind v4 glass UI setup.
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Next.js: samples here pass functions (formatters, seriesLegend, a dashboard's load), so put them in a file that starts with "use client".

Rolling year, own levels

Without a year it shows the 365 days up to the latest entry. Thresholds set where each level starts; a different hue keeps a second calendar on the page distinct.

Running

Kilometres per day, last 12 months

CalendarHeatmap

PropTypeDefaultDescription
data (required)readonly CalendarDatum[]NoneOne entry per day: { date: "2026-03-04", value: 12 }. Days without an entry count as 0.
yearnumberNoneShow one calendar year (Jan 1 – Dec 31). Otherwise start – end.
startstring | Date364 days before endSets the first day shown.
endstring | Datethe latest date in data (or today)Last day shown, the right edge of the grid (a date string or a Date); days after it are left out.
todaystring | Date | nullthe current dateDays after this one haven't happened: they're drawn as empty outlines and read "No data yet", never as zero (unless data has a value for them).
weekStart0 | 2 | 1 | 3 | 4 | 5 | 6from locale (Monday in most of the world)Sets the first day of the week, 0 = Sunday.
localestring"en"Locale for month / weekday names, the default week start and the default number format.
colorChartColor1Sets the hue of the levels: a palette slot, 1–8.
levelsnumber4Sets the number of non-zero levels.
thresholdsreadonly number[]equal steps up to the busiest dayValues where levels 2, 3, ... start.
cellSizenumberfits the width (11–18)Sets the cell size in px.
format((n: number) => string)formatCompact in localeFormats a day's value for the tooltips, announcements and data table: takes the number, returns the text shown.
valueLabelstring""What a value counts, e.g. "contributions". Shown in the tooltip and announcements.
legendbooleantrueShow the Less / More legend.
onDayClick((day: { date: string; value: number; }) => void)NoneCalled with a day on click, Enter or Space.
labelsPartial<CalendarHeatmapLabels>defaultCalendarHeatmapLabelsEvery other string, for translation: labels={{ less: "…" }}; omitted keys keep the English of defaultCalendarHeatmapLabels. All 6 keys of CalendarHeatmapLabels are listed in the key table under the props table.
aria-label (required)stringNoneAccessible name of the chart; describe what it shows.
CalendarHeatmapLabels keys and English defaults (6)
Pass any key in labels; the rest keep the defaults of defaultCalendarHeatmapLabels.
KeyEnglish default
lessLess
moreMore
instructionsUse the arrow keys to move by day or week; Page Up and Page Down move by month.
roleDescriptioncalendar heatmap
hintTap or hover a day for its value
futureNo data yet

CalendarHeatmapTable

PropTypeDefaultDescription
data (required)readonly CalendarDatum[]NoneOne entry per day: { date: "2026-03-04", value: 12 }. Days without an entry count as 0.
endstring | Datethe latest date in data (or today)Last day shown, the right edge of the grid (a date string or a Date); days after it are left out.
format((n: number) => string)formatCompact in localeFormats a day's value for the tooltips, announcements and data table: takes the number, returns the text shown.
startstring | Date364 days before endSets the first day shown.
localestring"en"Locale for month / weekday names, the default week start and the default number format.
yearnumberNoneShow one calendar year (Jan 1 – Dec 31). Otherwise start – end.
todaystring | Date | nullthe current dateDays after this one haven't happened: they're drawn as empty outlines and read "No data yet", never as zero (unless data has a value for them).
captionstringNoneVisually hidden caption that names the table.
labelsPartial<CalendarHeatmapTableLabels>defaultCalendarHeatmapTableLabelsStrings of the table: month / total headers and the future / notApplicable cell text. Merged over defaultCalendarHeatmapTableLabels. Every other string, for translation: labels={{ month: "…" }}; omitted keys keep the English of defaultCalendarHeatmapTableLabels. All 4 keys of CalendarHeatmapTableLabels are listed in the key table under the props table.
emptyStateReactNodeNoneShown when the range has no months (never, in practice).
CalendarHeatmapTableLabels keys and English defaults (4)
Pass any key in labels; the rest keep the defaults of defaultCalendarHeatmapTableLabels.
KeyEnglish default
monthMonth
totalTotal
futurefuture: string;
notApplicableNot applicable

Keyboard

KeysAction
TabFocus the calendar (the scroller is the focusable chart).
↑/↓Previous / next day.
←/→Previous / next week.
Page Up/Page DownPrevious / next month.
Home/EndJump to the first / last day.
Enter/SpaceActivate the day being read, when onDayClick is set.
EscapeClear the reading.

Accessibility

  • The calendar is a focusable figure named by its aria-label and described by the reading hint; the keyboard keeps the day being read in view while the weeks scroll sideways on narrow screens.
  • Days that have not happened yet are outlined, never painted as zero, and every day has a text value in its tooltip and in the table view.
  • CalendarHeatmapTable is the table view: pair it with ChartCard's table prop (Chart / Table tabs) so every value can be read without color or sight.
  • With reduced motion on, the day cells start at their final colors and a data change jumps straight to the new state.

All exports on this page

  • CalendarHeatmap — A GitHub-style contribution calendar: one column per week, one row per weekday, a cell per day coloured by level.
  • CalendarHeatmapTable — Every day's value as a month × day-of-month table (with a total per month).
  • defaultCalendarHeatmapLabels — The built-in English strings of CalendarHeatmap; spread it into your own labels and change what you need.
  • defaultCalendarHeatmapTableLabels — English defaults of CalendarHeatmapTableLabels.
  • defaultCalendarLabels — The English strings of Calendar.
  • isoDate — "YYYY-MM-DD" for a day number.
  • localeWeekStart — First day of the week for a locale (0 = Sunday), from Intl when the browser has week info.
  • toDayNumber — A calendar day from "YYYY-MM-DD" (or an ISO timestamp: its date part), a Date (its local date) or a timestamp.

When to use the calendar heatmap

  • Use it as a GitHub contribution graph for commits, workouts, check-ins or support replies per day across a year, where streaks and quiet weeks are what readers look for.
  • Use it to show seasonality in daily counts, such as orders by day over twelve months, with year set to one calendar year or start and end for a rolling window.
  • Make days actionable with onDayClick, for example opening that day's activity log in a side panel, while the tooltip and keyboard readout name the value using valueLabel.
  • Skip it when you need to compare exact values or show a trend line, because a Bar chart or Line chart reads numbers better than five or so color levels do.
  • Pair it with ChartCard for the title and a Select for the year, or with DateRangePicker when the window is arbitrary, since start and end accept any range.

Frequently asked questions

48 charts pages in all: browse them on Charts.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .