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} />;
}import { CalendarHeatmap } from "@senvenli/react/charts";Examples
Fixed steps and a press
Your own thresholds keep the shading comparable between periods; a press opens the day.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
- The pattern is by weekday and hour, not by date. Heatmap
- One status per day matters, not an amount. Tracker
- The trend over time matters more than single days. Line chart
Accessibility
Keyboard
| Keys | What happens |
|---|---|
| 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 | Description |
|---|---|---|---|
title | string | – | What the chart shows, over it; leave it out when a card or a heading already says so. |
aria-label | string | – | Names the chart when it has no visible |
period | string | – | |
isLoading | boolean | – | |
emptyState | React.ReactNode | – | Shown instead of the plot when there is no data: an |
dataRequired | readonly CalendarHeatmapDatum[] | – | |
start | ChartDay | – | The first and last day drawn; the data's range by default. |
end | ChartDay | – | |
thresholds | readonly [number, number, number, number] | – | Four ascending lower bounds of the four intensity steps; from the data's quartiles by default. |
valueFormatter | ChartValueFormatter | plain | |
onDayPress | (day: { date: CalendarDate; value: number | undefined; }) => void | – |
titlestringWhat the chart shows, over it; leave it out when a card or a heading already says so.
aria-labelstringNames the chart when it has no visible
title(a card's heading already says what it shows).periodstringisLoadingbooleanemptyStateReact.ReactNodeShown instead of the plot when there is no data: an
EmptyState size="small"or text; "No data" by default.dataRequiredreadonly CalendarHeatmapDatum[]startChartDayThe first and last day drawn; the data's range by default.
endChartDaythresholdsreadonly [number, number, number, number]Four ascending lower bounds of the four intensity steps; from the data's quartiles by default.
valueFormatterChartValueFormatterDefaultplainonDayPress(day: { date: CalendarDate; value: number | undefined; }) => void