GitHub Activity Calendar

A GitHub-style contribution calendar that renders one year of daily activity as a grid of small colored squares, with a total-contributions heading and a Less/More legend. It supports four color schemes (green, blue, purple, orange) and is driven by an optional staticData array, or generates random sample data when none is given.

GitHub Activity Calendar
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

pnpm dlx shadcn@latest add @elements/github-activity-calendar

Requires @elements in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { GitHubActivityCalendar } from "@/components/elements/github-activity-calendar"export function Example() {  return <GitHubActivityCalendar username="octocat" />}
  • Showing a user's or team's yearly activity, streaks, or commit-style history on a profile, dashboard, or report page
  • Displaying any daily metric that fits a 0 to 4 intensity scale, using staticData with your own levels
  • Adding a GitHub-like heatmap that should match a themed color (green, blue, purple, or orange) in light and dark mode
  • Prototyping a contribution graph with generated sample data before wiring real data

Examples

Generated sample data for the current year

With no staticData, the component generates random sample levels for every day of the given year. The username is required but is only used as an effect dependency; no network request is made.

generated-sample-data-for-the-current-year.tsx
import { GitHubActivityCalendar } from "@/components/elements/github-activity-calendar"export function SampleCalendar() {  return <GitHubActivityCalendar username="octocat" year={2025} />}

Static data with the blue color scheme

Pass your own days as staticData. Each entry needs a date string (YYYY-MM-DD), a count, and a level from 0 to 4. The example derives the element type from the component so the literal types check.

static-data-with-the-blue-color-scheme.tsx
import { GitHubActivityCalendar } from "@/components/elements/github-activity-calendar"const days: NonNullable<React.ComponentProps<typeof GitHubActivityCalendar>["staticData"]> = [  { date: "2024-01-01", count: 3, level: 2 },  { date: "2024-01-02", count: 0, level: 0 },  { date: "2024-01-03", count: 7, level: 4 },];export function StaticCalendar() {  return (    <GitHubActivityCalendar      username="octocat"      year={2024}      staticData={days}      colorScheme="blue"    />  );}

Styled card with the orange color scheme

className is merged onto the root div, so you can constrain width or add a border and padding. Other HTML div attributes such as aria-label also pass through.

styled-card-with-the-orange-color-scheme.tsx
import { GitHubActivityCalendar } from "@/components/elements/github-activity-calendar"export function ActivityCard() {  return (    <section className="max-w-3xl rounded-lg border p-4">      <GitHubActivityCalendar        username="shadcn"        year={2025}        colorScheme="orange"        aria-label="Contribution activity for shadcn in 2025"      />    </section>  );}

API reference

PropTypeDefaultDescription
usernamestring—GitHub username. Required. It is only used as a dependency of the data-loading effect and does not fetch anything in this implementation.
staticDataContributionDay[] (each item: { date: string; count: number; level: 0 | 1 | 2 | 3 | 4 })—Optional array of daily contribution entries to display. When provided, the component uses it and skips sample generation. When omitted, random sample data for the given year is generated.
yearnumbernew Date().getFullYear()Calendar year to display. It is used for the heading text and for generating sample data when staticData is not provided.
colorScheme"green" | "blue" | "purple" | "orange""green"Hue used for activity levels 1 to 4. Level 0 always uses the neutral palette.
classNamestring—Additional classes merged onto the root div via cn(). The root already has flex flex-col gap-2.
...propsReact.HTMLAttributes<HTMLDivElement>—All other standard div attributes (for example id, style, aria-label, role) are spread onto the root div. Note that the root div's data-slot attribute is set by the component.

Accessibility

  • The grid is built from plain divs with no role, list, or table semantics, so screen readers will not announce it as a calendar. Pass role and aria-label through props (for example role="img" with a descriptive aria-label, or a labelled region) to give it a text alternative.
  • Each active day square exposes its details only through a title attribute (e.g. '3 contributions on 2024-01-02'). This tooltip is visible on hover only and is not reliably exposed to assistive technology or keyboard users.
  • Intensity is encoded only by color. Pair the Less/More legend with the total count text, and consider providing the same data in an accessible table or list for users who cannot distinguish the hues.
  • The total-contributions text is real text and is readable by screen readers, which gives a summary even when the grid is not announced.
  • Color contrast of the level 1 and level 2 swatches against the background may be low in some schemes; verify contrast in both light and dark mode for your brand colors.
  • The loading state is a pulsing placeholder with no aria-busy or status text; add aria-busy or a live region in the consuming page if loading must be announced.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "GitHub Activity Calendar" component (elements/github-activity-calendar) from its shadcn registry.1. Install it with: npx shadcn@latest add @elements/github-activity-calendar2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: username, staticData, year, colorScheme, className, ...props.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { GitHubActivityCalendar } from "@/components/elements/github-activity-calendar"export function Example() {  return <GitHubActivityCalendar username="octocat" />}```

Files & dependencies

  • registry/default/blocks/github/github-activity-calendar/components/elements/github-activity-calendar.tsx

Looks similar, elsewhere