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.jsonContributions
CalendarHeatmapCalendarHeatmapTableisoDatetoDayNumberlocaleWeekStart- +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
import { CalendarHeatmapTable, CalendarHeatmap, type CalendarDatum } from "@/components/sheenui/charts/calendar-heatmap";
import { ChartCard } from "@/components/sheenui/charts/chart-parts/chart-card";
import { formatCompact } from "@/components/sheenui/charts/chart-utils";
// Package build (after the first npm release, or a packed tarball): import { ChartCard, formatCompact, CalendarHeatmapTable, CalendarHeatmap, type CalendarDatum } from "@sheenui/theme";
const data: CalendarDatum[] = [
{ date: "2026-03-04", value: 12 },
{ date: "2026-03-05", value: 4 },
{ date: "2026-03-09", value: 7 },
{ date: "2026-06-18", value: 15 },
{ date: "2026-09-02", value: 2 },
];
const total = data.reduce((sum, d) => sum + d.value, 0);
export function Example() {
return (
<ChartCard
title="Contributions"
aside={<span className="text-2xl font-semibold">{formatCompact(total)}</span>}
table={<CalendarHeatmapTable data={data} year={2026} />}
>
<CalendarHeatmap
data={data}
year={2026}
today="2026-10-28" // default: the current date; later days are outlined
locale="en-GB" // week starts on Monday; month & weekday names from Intl
valueLabel="contributions"
aria-label="Contributions per day in 2026"
/>
</ChartCard>
);
}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.tsxcomponents/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.tslib/{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
import { CalendarHeatmap, type CalendarDatum } from "@/components/sheenui/charts/calendar-heatmap";
// Package build (after the first npm release, or a packed tarball): import { CalendarHeatmap, type CalendarDatum } from "@sheenui/theme";
const workouts: CalendarDatum[] = [
{ date: "2026-01-06", value: 5 },
{ date: "2026-02-14", value: 10 },
{ date: "2026-05-21", value: 3 },
{ date: "2026-08-09", value: 8 },
{ date: "2026-10-02", value: 6 },
];
export function Example() {
return (
<CalendarHeatmap
data={workouts}
color={3}
levels={3}
thresholds={[4, 8]} // level 1: 1–3, level 2: 4–7, level 3: 8+
valueLabel="km"
aria-label="Kilometres run per day, last 12 months"
/>
);
}CalendarHeatmap
CalendarHeatmapLabels keys and English defaults (6)
CalendarHeatmapTable
CalendarHeatmapTableLabels keys and English defaults (4)
Keyboard
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
Related pages
48 charts pages in all: browse them on Charts.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .