Mark Yo

Heatmap Chart

Component

About

An animated GitHub-style contribution calendar that shades each day by activity level, fades cells in week by week as it scrolls into view, and lets arrow keys read each day's value.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Heatmap Chart to your project and fits it to your theme.

Code

How Heatmap Chart is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card";
import { HeatmapChart, type HeatmapDatum } from "@/components/ui/chart-heatmap";

// Deterministic pseudo-random data so the demo renders the same every time.
function generateData(): HeatmapDatum[] {
  let seed = 42;
  const rand = () => {
    seed = (seed * 9301 + 49297) % 233280;
    return seed / 233280;
  };

  const data: HeatmapDatum[] = [];
  const now = new Date();
  for (let i = 365; i >= 0; i--) {
    const d = new Date(now);
    d.setDate(d.getDate() - i);
    const date = d.toISOString().slice(0, 10);
    const value = rand() < 0.3 ? 0 : Math.round(rand() * 9);
    data.push({ date, value });
  }
  return data;
}

const data = generateData();
const total = data.reduce((sum, d) => sum + d.value, 0);

export default function HeatmapChartDemo() {
  return (
    <Card className="w-full max-w-3xl">
      <CardHeader>
        <CardTitle>Contributions</CardTitle>
        <CardDescription>
          {total.toLocaleString()} contributions in the last year
        </CardDescription>
      </CardHeader>
      <CardContent>
        <HeatmapChart
          data={data}
          title="Daily contributions over the last year"
        />
      </CardContent>
    </Card>
  );
}

Dependencies

More by Mark Yo

View all
  • Loader

    Loader

    67
  • Pricing Table

    Pricing Table

    24
  • Bento Grid

    Bento Grid

    10
  • Wallet Card

    Wallet Card

    4
  • Expandable Tabs

    Expandable Tabs

    4
  • Image Gallery

    Image Gallery

    3
  • CTA Section

    CTA Section

    3
  • Bar Chart

    Bar Chart

    1