About
A GitHub-style activity grid with one square per day, month and weekday labels, a hover tooltip and a legend. Fully keyboard navigable, with sample data built in and no extra dependencies.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Calendar Heatmap to your project and fits it to your theme.
Code
How Calendar Heatmap is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
// This is a file with a demo for your component
// That's what users will see in the preview
// Create new files in this directory to add more demos
"use client";
import * as React from "react";
import { GitCommitHorizontal } from "lucide-react";
import { Component, type HeatmapDay } from "@/components/ui/calendar-heatmap";
import { cn } from "@/lib/utils";
const RANGES = [
{ label: "6 months", weeks: 26 },
{ label: "1 year", weeks: 52 },
];
export default function DemoOne() {
const [range, setRange] = React.useState(1);
const [picked, setPicked] = React.useState<HeatmapDay | null>(null);
return (
<div className="flex min-h-[420px] w-full flex-col items-center justify-center gap-5 bg-background px-4 py-10 text-foreground">
<div className="flex w-full max-w-4xl flex-wrap items-center justify-between gap-3">
<div className="flex items-center gap-2.5">
<span className="grid size-9 place-items-center rounded-lg bg-primary text-primary-foreground">
<GitCommitHorizontal className="size-4" aria-hidden="true" />
</span>
<div>
<h2 className="text-base font-semibold leading-5">Commit activity</h2>
<p className="text-xs text-muted-foreground">Hover a day, or use the arrow keys</p>
</div>
</div>
<div role="group" aria-label="Time range" className="inline-flex rounded-full border border-border bg-card p-0.5">
{RANGES.map((r, i) => (
<button
key={r.label}
type="button"
aria-pressed={range === i}
onClick={() => setRange(i)}
className={cn(
"h-8 rounded-full px-4 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
range === i ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:text-foreground"
)}
>
{r.label}
</button>
))}
</div>
</div>
<Component key={RANGES[range].weeks} weeks={RANGES[range].weeks} unit="commit" onDayClick={setPicked} />
<p className="h-4 text-xs text-muted-foreground" role="status">
{picked ? "Selected " + picked.date + ": " + picked.count + " commits" : ""}
</p>
</div>
);
}
















