# C calendar heatmap 2

> Habit streak — three months, weeks start Monday

A shadcn/ui block from the [@cnippet](https://ui.cnippet.dev/?utm_source=shadcn.exchange) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/cnippet/c-calendar-heatmap-2).

- Page, with a live preview: https://shadcn.exchange/r/cnippet/c-calendar-heatmap-2
- Screenshot: https://shadcn.exchange/shot/cnippet/c-calendar-heatmap-2/light.png
- Registry item: https://ui.cnippet.dev/r/c-calendar-heatmap-2.json
- Categories: calendar heatmap
- Listed: 2026-10-27, source last changed 2026-10-27

## Install

```bash
npx shadcn@latest add https://shadcn.exchange/r/cnippet/c-calendar-heatmap-2.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `@cnippet/calendar-heatmap`, `@cnippet/chart-card`

## Files

### `registry/default/chart-variants/c-calendar-heatmap-2.tsx`

```tsx
"use client";

import { CalendarHeatmap } from "@/registry/default/charts/calendar-heatmap";
import { ChartCard } from "@/registry/default/charts/chart-card";

const START = Date.UTC(2026, 7, 1);
const DAYS = 92;

// Deterministic habit log: 1 = done, 0 = missed. A streak builds up over time.
const data = Array.from({ length: DAYS }, (_, i) => ({
  date: new Date(START + i * 86_400_000).toISOString().slice(0, 10),
  value: i > 60 || (i * 7) % 5 !== 0 ? 1 : 0,
}));
const done = data.filter((d) => d.value === 1).length;

export default function HabitStreak() {
  return (
    <ChartCard
      className="max-w-sm"
      description="Daily 20-minute run, August to October. Weeks start on Monday."
      footer={`${done} of ${DAYS} days done; current streak 31 days.`}
      title="Running habit"
    >
      <CalendarHeatmap
        cellLabel={(day) => `${day.date}: ${day.value ? "done" : "missed"}`}
        color="var(--success)"
        data={data}
        endDate="2026-10-31"
        minCellSize={14}
        showLegend={false}
        weekStart={1}
      />
    </ChartCard>
  );
}
```
