GitHub Contributions

Visualize year-long GitHub contribution activity with daily counts, tooltips, and a profile link.

date-fns

Installation

pnpm dlx shadcn-svelte@latest add http://sveltekit-prerender/r/github-contributions.json

Usage

usage.svelte

Features

  • Shows a full year of daily activity with a color legend and total count
  • Shows the contribution count and date in a tooltip for each day
  • Links the contribution total to the requested user's GitHub profile
  • Works with any API compatible with the GitHub Contributions API

Examples

Custom theme

Apply a warm orange palette to every contribution level.

Localized labels

Translate month, total count, and legend labels.

Biểu đồ đóng gópTh1Th2Th3Th4Th5Th6
1368 hoạt động trong năm 2025
Ít hơn 0 contributions1 contributions2 contributions3 contributions4 contributions Nhiều hơn

Props

GitHubContributions

Ready-to-use contribution graph loaded from a GitHub username.

NameTypeDefaultDescription
usernamestringrequiredGitHub username whose recent contributions are displayed.
classstringundefinedAdditional classes applied to the contribution graph.

ContributionGraph

Context provider and layout root for a custom contribution graph.

NameTypeDefaultDescription
dataActivity[]requiredDaily activity records rendered by the graph.
blockMarginnumber4Gap between contribution blocks in pixels.
blockRadiusnumber2Corner radius of each contribution block.
blockSizenumber12Width and height of each contribution block.
fontSizenumber14Base graph label size in pixels.
labelsLabelsundefinedOverrides for month, legend, and total-count labels.
maxLevelnumber4Highest contribution intensity level.
totalCountnumbersum of data countsOptional total that replaces the value calculated from data.
weekStartDay0Day of the week used to start each graph column.
childrenSnippetrequiredGraph composition rendered within the shared context.
refHTMLDivElement | nullnullBindable reference to the graph root.

ContributionGraphCalendar

Scrollable SVG calendar that exposes each activity to a render snippet.

NameTypeDefaultDescription
childrenSnippet<[{ activity: Activity; dayIndex: number; weekIndex: number }]>requiredRenderer called for every activity block.
hideMonthLabelsbooleanfalseHides the month labels above the calendar.
titlestring'Contribution Graph'Accessible title rendered inside the SVG.
refHTMLDivElement | nullnullBindable reference to the calendar container.

ContributionGraphBlock

A positioned contribution rectangle using the graph context.

NameTypeDefaultDescription
activityActivityrequiredActivity record represented by the block.
dayIndexnumberrequiredRow position within the week.
weekIndexnumberrequiredColumn position within the year.
refSVGRectElement | nullnullBindable reference to the SVG rectangle.

ContributionGraphFooter

Footer layout for totals and the contribution legend.

NameTypeDefaultDescription
childrenSnippetrequiredFooter content.
refHTMLDivElement | nullnullBindable reference to the footer element.

ContributionGraphLegend

Contribution intensity legend with optional custom level rendering.

NameTypeDefaultDescription
childrenSnippet<[{ level: number }]>undefinedOptional renderer for each legend level.
refHTMLDivElement | nullnullBindable reference to the legend element.

ContributionGraphTotalCount

Total contribution label with an optional custom renderer.

NameTypeDefaultDescription
childrenSnippet<[{ totalCount: number; year: number }]>undefinedOptional renderer receiving the total count and year.
refHTMLDivElement | nullnullBindable reference to the default total-count element.