# Calendar heatmap

A value per day over weeks, as shaded cells in a calendar grid.

- Family: charts
- Import: `import { CalendarHeatmap } from "@senvenli/react/charts";`
- Page: https://design.senvenli.com/docs/components/calendar-heatmap
- JSON: https://design.senvenli.com/docs/components/calendar-heatmap.json

## Example: Orders per day

Twelve weeks of days, shaded in four steps from the data's quartiles.

```tsx
import { CalendarDate } from "@internationalized/date";
import { CalendarHeatmap } from "@senvenli/react/charts";

// Twelve fixed weeks from Monday, January 5, 2026. Calendar dates carry no time zone, so no day shifts.
const START = new CalendarDate(2026, 1, 5);
const ORDERS = Array.from({ length: 84 }, (_, index) => {
  const isWeekend = index % 7 >= 5;
  return { date: START.add({ days: index }), value: ((index * 7) % 13) * 3 + (isWeekend ? 2 : 18) };
});

export default function Example() {
  return <CalendarHeatmap title="Orders per day" period="January 5 – March 29, 2026" data={ORDERS} />;
}
```

## Examples

### Fixed steps and a press

Your own thresholds keep the shading comparable between periods; a press opens the day.

```tsx
import { useState } from "react";
import { CalendarDate } from "@internationalized/date";
import { CalendarHeatmap } from "@senvenli/react/charts";
import { Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

const START = new CalendarDate(2026, 2, 2);
const TICKETS = Array.from({ length: 56 }, (_, index) => ({ date: START.add({ days: index }), value: (index * 5) % 17 }));

export default function Example() {
  const [day, setDay] = useState("Press a day to see its tickets.");
  return (
    <Stack space="space-150">
      <CalendarHeatmap
        title="Support tickets"
        period="February 2 – March 29, 2026"
        data={TICKETS}
        thresholds={[1, 5, 10, 15]}
        onDayPress={({ date, value }) => setDay(`${date.toString()}: ${value ?? 0} tickets`)}
      />
      <Text size="body-small" tone="subtle">{day}</Text>
    </Stack>
  );
}
```

## Guidelines

### When to use it

- Daily activity over months.

### Use something else when

- [heatmap](https://design.senvenli.com/docs/components/heatmap.md): The pattern is by weekday and hour, not by date.
- [tracker](https://design.senvenli.com/docs/components/tracker.md): One status per day matters, not an amount.
- [line-chart](https://design.senvenli.com/docs/components/line-chart.md): The trend over time matters more than single days.

## Accessibility

Keyboard:

- Arrow keys: Move between days.

Built in:

- A "Show as table" button shows the same data as a table, which screen readers get by default.

You provide:

- A title that says what the figure is.

## API reference

### CalendarHeatmap

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| title | `string` |  | no | What the chart shows, over it; leave it out when a card or a heading already says so. |
| aria-label | `string` |  | no | Names the chart when it has no visible `title` (a card's heading already says what it shows). |
| period | `string` |  | no |  |
| isLoading | `boolean` |  | no |  |
| emptyState | `React.ReactNode` |  | no | Shown instead of the plot when there is no data: an `EmptyState size="small"` or text; "No data" by default. |
| data | `readonly CalendarHeatmapDatum[]` |  | yes |  |
| start | `ChartDay` |  | no | The first and last day drawn; the data's range by default. |
| end | `ChartDay` |  | no |  |
| thresholds | `readonly [number, number, number, number]` |  | no | Four ascending lower bounds of the four intensity steps; from the data's quartiles by default. |
| valueFormatter | `ChartValueFormatter` | `plain` | no |  |
| onDayPress | `(day: { date: CalendarDate; value: number \| undefined; }) => void` |  | no |  |

### Tokens it reads

`--ds-background-brand-subtle`, `--ds-background-neutral`, `--ds-background-neutral-pressed`, `--ds-background-selected-hovered`, `--ds-background-selected-pressed`, `--ds-border`, `--ds-border-bold`, `--ds-border-focused`, `--ds-chart-1`, `--ds-chart-2`, `--ds-chart-3`, `--ds-chart-4`, `--ds-chart-5`, `--ds-chart-neutral`, `--ds-icon-danger`, `--ds-icon-success`, `--ds-icon-warning`, `--ds-link`, `--ds-radius-medium`, `--ds-radius-small`, `--ds-radius-xsmall`, `--ds-shadow-overlay`, `--ds-space-050`, `--ds-space-075`, `--ds-space-100`, `--ds-space-150`, `--ds-space-200`, `--ds-space-300`, `--ds-space-400`, `--ds-surface-overlay`, `--ds-surface-raised`, `--ds-text`, `--ds-text-danger`, `--ds-text-subtle`, `--ds-text-subtlest`, `--ds-text-success`

## Related

- [tracker](https://design.senvenli.com/docs/components/tracker.md)
