# React Native Calendar Heatmap (Pro)

> A React Native calendar heatmap for iOS, Android and the web: days as shaded squares a week per column, like GitHub contributions, with month and weekday labels, a Less–More scale, tooltips by touch, pointer or keyboard, and a screen-reader summary of the total and the busiest day.

# Calendar heatmap Pro

Days as shaded squares, a week per column, as GitHub draws contributions: commits, workouts, sales, habits. Rows take a `date` (a `Date` or `'YYYY-MM-DD'`, read as a local day) and a `value`; days without a row are empty. Shades step from faint to the full color by each day's share of the busiest. On a narrow screen the chart shows the latest weeks that fit at a size a finger can hit.

```tsx
import { HeatmapChart } from '@patine-ui/pro';
```

## Live data

```tsx live
import { useState } from 'react';
import { View } from 'react-native';
import { Button, Text } from 'patine-ui';
import { HeatmapChart } from '@patine-ui/pro';

const roll = () =>
  Array.from({ length: 182 }, (_, i) => {
    const date = new Date(2026, 4, 1 + i);
    const weekend = date.getDay() === 0 || date.getDay() === 6;
    return { date, value: Math.random() < (weekend ? 0.75 : 0.15) ? 0 : Math.round(Math.random() * (weekend ? 3 : 12)) };
  });

export default function Example() {
  const [data, setData] = useState(roll);
  const [day, setDay] = useState(null);
  return (
    <View style={{ width: 600, maxWidth: '100%', gap: 8 }}>
      <View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
        <Text>{day ? `${day.row.value ?? 0} commits on ${day.row.date.toDateString()}` : 'Hover or press a day'}</Text>
        <Button size="sm" variant="outline" onPress={() => setData(roll())}>Shuffle</Button>
      </View>
      <HeatmapChart data={data} valueLabel="Commits" onPointSelect={setDay} accessibilityLabel="Commits, last six months" />
    </View>
  );
}
```

## Example: a year of workouts

A fitness app's year: each square is a day, darker for longer workouts, so streaks and gaps show at a glance. Press a day for its details.

```tsx live wide
import { useState } from 'react';
import { View } from 'react-native';
import { Text } from 'patine-ui';
import { HeatmapChart } from '@patine-ui/pro';

const data = Array.from({ length: 365 }, (_, i) => {
  const date = new Date(2026, 0, 1 + i);
  const holiday = i > 200 && i < 214;
  const rest = date.getDay() === 1 || date.getDay() === 4;
  return { date, value: holiday || rest ? 0 : Math.round(20 + ((i * 37) % 70)) };
});

export default function Example() {
  const [day, setDay] = useState<{ row: { date: Date; value: number } } | null>(null);
  const total = data.filter((d) => d.value).length;
  return (
    <View style={{ width: '100%', gap: 8 }}>
      <Text>{day ? `${day.row.value ? `${day.row.value} min` : 'Rest day'} on ${day.row.date.toDateString()}` : `${total} workouts in 2026`}</Text>
      <HeatmapChart data={data} valueLabel="Minutes" color="#16A34A" levels={4} weekStartsOn={1} onPointSelect={setDay} accessibilityLabel="Workout minutes each day of 2026" />
    </View>
  );
}
```

## Colors and weeks

```tsx live
import { HeatmapChart } from '@patine-ui/pro';

const data = Array.from({ length: 120 }, (_, i) => ({ date: new Date(2026, 6, 1 + i), value: (i * 37) % 9 }));

export default function Example() {
  return <HeatmapChart data={data} color="#7C3AED" levels={6} weekStartsOn={1} valueLabel="Workouts" style={{ width: 420 }} />;
}
```

## Props

The [shared chart props](./charts#shared-props) (its height follows its width), and:

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `data` | `{ date, value }[]` | — | One row per day; rows for the same day add up. |
| `dateKey` / `valueKey` | `string` | `'date'` / `'value'` | |
| `valueLabel` | `string` | `'Value'` | What the value counts, in the tooltip and summary. |
| `startDate` / `endDate` | `Date` | the data's | The span shown. |
| `weekStartsOn` | `number` | `0` | 0 is Sunday, 1 Monday. |
| `color` | `string` | the theme's primary | The darkest shade. |
| `levels` | `number` | `4` | Shades for days with a value. |
| `cellSize` | `number` | `16` | The largest a day may grow, in px. |
| `showMonthLabels` / `showWeekdayLabels` / `showScale` | `boolean` | `true` | |
