Rendyn

Component library

189 components

Product blocks

Contribution Graph

Contribution Graph turns supplied activity records into a calendar-like grid.

Interactive exampleReact Tailwind CSS

Practical React example

Show dated activity counts with a readable summary of the period and total.

Before you copy and paste

Use the composed primitives together under their required provider, where one is present. Copy components/kibo-ui/contribution-graph/index.tsx and its returned support files from the Code tab; preserve the project-relative paths.

Listed package dependencies: date-fns.

Use the Code tab for the component files and installation instructions, then adapt the imports in this example to your project.

Show dated activity counts with a readable summary of the period and total

// Usage adapted from Kibo UI's pinned MIT source.
// Copyright (c) 2023 — Present shadcnblocks. See ./LICENSES.md.
"use client";

import {
  ContributionGraph,
  ContributionGraphBlock,
  ContributionGraphCalendar,
  ContributionGraphFooter,
  ContributionGraphLegend,
  ContributionGraphTotalCount,
} from "@/components/kibo-ui/contribution-graph";
import { eachDayOfInterval, endOfYear, formatISO, startOfYear } from "date-fns";

const maxCount = 20;
const maxLevel = 4;
const now = new Date();
const days = eachDayOfInterval({
  start: startOfYear(now),
  end: endOfYear(now),
});

const data = days.map((date) => {
  const c = Math.round(
    Math.random() * maxCount - Math.random() * (0.8 * maxCount)
  );
  const count = Math.max(0, c);
  const level = Math.ceil((count / maxCount) * maxLevel);

  return {
    date: formatISO(date, { representation: "date" }),
    count,
    level,
  };
});

const Example = () => (
  <ContributionGraph data={data}>
    <ContributionGraphCalendar>
      {({ activity, dayIndex, weekIndex }) => (
        <ContributionGraphBlock
          activity={activity}
          dayIndex={dayIndex}
          weekIndex={weekIndex}
        />
      )}
    </ContributionGraphCalendar>
    <ContributionGraphFooter>
      <ContributionGraphTotalCount />
      <ContributionGraphLegend />
    </ContributionGraphFooter>
  </ContributionGraph>
);

export default Example;

Usage example adapted from Kibo UI's pinned MIT source. Retain the source licence notices when copying.

Use consistent dates, levels and counts, and explain the level scale outside the colored cells. Keep totalCount aligned with the same period as the data.

Customization

ContributionGraphProps.data
Required; Activity[].
ContributionGraphProps.blockMargin
Optional; number.
ContributionGraphProps.blockRadius
Optional; number.
ContributionGraphProps.blockSize
Optional; number.
ContributionGraphProps.fontSize
Optional; number.
ContributionGraphProps.labels
Optional; Labels.
ContributionGraphProps.maxLevel
Optional; number.
ContributionGraphProps.style
Optional; CSSProperties.
ContributionGraphProps.totalCount
Optional; number.
ContributionGraphProps.weekStart
Optional; WeekDay.
ContributionGraphProps.children
Required; ReactNode.
ContributionGraphProps.className
Optional; string.
ContributionGraphBlockProps.activity
Required; Activity.
ContributionGraphBlockProps.dayIndex
Required; number.

Integration notes

  • Do not equate a visual activity level with productivity or quality without a justified definition.
  • Provide textual values or a table for readers who cannot use color or pointer tooltips.

Component source: Kibo UI documentation . These examples describe the version imported into Rendyn. Upstream APIs may have changed; retain the source licence notices when adapting the code.

Better with your agent

Give your agent taste.

The best way to use Rendyn is through MCP. Let your agent find the right component, compare previews and bring the source into your project.

All components are free. Sign up only to connect MCP.

Connect to MCP