# React Native Date Range Picker

> React Native date range picker (check-in / check-out) with presets such as Last 7 days, min/max nights, multiple ranges and multiple date selection, built on the calendar.

# Date range & multiple dates

Pick a check-in / check-out date range, several ranges, or several separate dates, in React Native. `DatePicker` (and `Calendar`) switch selection model with `mode`. TypeScript narrows `value` and `onValueChange` for each mode.

| `mode` | `value` | `onValueChange` | Extra props |
| --- | --- | --- | --- |
| `'single'` (default) | `Date \| null` | `(date: Date) => void` | — |
| `'range'` | `DateRange` (`{ start: Date \| null; end: Date \| null }`) | `(range: DateRange) => void` | `presets`, `presetsProps`, `minRangeDays`, `maxRangeDays`, `allowSingleDayRange` |
| `'multiple'` | `Date[]` | `(dates: Date[]) => void` | `maxSelections` |
| `'ranges'` | `DateRange[]` | `(ranges: DateRange[]) => void` | `maxRanges`, `minRangeDays`, `maxRangeDays`, `allowSingleDayRange` |

The modes are also exported as constants: `mode={CALENDAR_MODE.ranges}`.

## Example: book a stay

A rental's calendar: each night shows its price, two nights are sold, the stay is at least two nights, and the total updates as the guest picks.

```tsx live
import { useState } from 'react';
import { Button, DatePicker, HStack, Text, VStack, addDays, startOfDay, toDateKey } from 'patine-ui';
import type { DateRange } from 'patine-ui';

const today = startOfDay(new Date());
const nightly = (date: Date) => (date.getDay() === 5 || date.getDay() === 6 ? 210 : 165);
const markedDates = Object.fromEntries(
  Array.from({ length: 90 }, (_, i) => addDays(today, i)).map((date, i) => [
    toDateKey(date),
    i === 12 || i === 13 ? { label: 'Sold', disabled: true } : { label: `$${nightly(date)}` },
  ])
);

export default function Example() {
  const [stay, setStay] = useState<DateRange>({ start: null, end: null });
  const { start, end } = stay;
  const nights = start && end ? Array.from({ length: Math.round((+end - +start) / 864e5) }, (_, i) => addDays(start, i)) : [];
  const total = nights.reduce((sum, night) => sum + nightly(night), 0);
  return (
    <VStack gap="md">
      <VStack gap="xs">
        <Text weight="semibold">Pine Hollow Cabin · Lake Tahoe</Text>
        <Text size="sm" color="textSecondary">2-night minimum · free cancellation for 48 hours</Text>
      </VStack>
      <DatePicker
        mode="range"
        value={stay}
        onValueChange={setStay}
        minDate={today}
        maxDate={addDays(today, 89)}
        minRangeDays={2}
        markedDates={markedDates}
      />
      <HStack justify="space-between" align="center">
        <Text weight="medium">{nights.length ? `${nights.length} nights · $${total.toLocaleString()}` : 'Add your dates'}</Text>
        <Button disabled={!nights.length}>Reserve</Button>
      </HStack>
    </VStack>
  );
}
```

## Range

```tsx live
import { useState } from 'react';
import { Text } from 'react-native';
import { DatePicker, formatDate } from 'patine-ui';
import type { DateRange } from 'patine-ui';

export default function Example() {
  const [range, setRange] = useState<DateRange>({ start: null, end: null });
  const nights =
    range.start && range.end
      ? Math.round((+range.end - +range.start) / 864e5)
      : 0;
  return (
    <>
      <DatePicker
        mode="range"
        value={range}
        onValueChange={setRange}
        minDate={new Date()}
      />
      <Text style={{ textAlign: 'center', color: '#6E685E' }}>
        {range.start ? formatDate(range.start) : 'Check-in'} →{' '}
        {range.end ? formatDate(range.end) : 'Check-out'}
        {nights ? `  ·  ${nights} night${nights > 1 ? 's' : ''}` : ''}
      </Text>
    </>
  );
}
```

### How taps work

1. **First tap** sets the start: `onValueChange({ start: day, end: null })`.
2. **Second tap** on or after the start sets the end: `onValueChange({ start, end: day })`.
3. A tap **before** the start, or any tap **after a complete range**, starts a new range from that day.

The band between start and end uses `primaryMuted`; the ends use `primary`.

### Ranges never cross disabled days

If the days between start and the tapped day include a disabled one (from `minDate`/`maxDate`, `isDateDisabled` or `markedDates`), the tap starts a **new range** instead of producing a range that spans an unavailable night. That's exactly what booking flows need:

```tsx live
import { useState } from 'react';
import { DatePicker, toDateKey, addDays } from 'patine-ui';
import type { DateRange } from 'patine-ui';

export default function Example() {
  const today = new Date();
  const booked = new Set([
    toDateKey(addDays(today, 4)),
    toDateKey(addDays(today, 5)),
    toDateKey(addDays(today, 12)),
  ]);
  const [range, setRange] = useState<DateRange>({ start: null, end: null });
  return (
    <DatePicker
      mode="range"
      value={range}
      onValueChange={setRange}
      minDate={today}
      isDateDisabled={(d) => booked.has(toDateKey(d))}
    />
  );
}
```

### Minimum and maximum length

Length is measured in **days between start and end** (nights): a range from the 10th to the 13th is 3.

| Prop | Effect when violated |
| --- | --- |
| `minRangeDays` | A second tap that would be too short is **ignored**; the start stays selected |
| `maxRangeDays` | A second tap that would be too long **starts a new range** from that day |
| `allowSingleDayRange={false}` | Tapping the start again is ignored (by default it makes a one-day range, `start === end`) |

```tsx live
import { useState } from 'react';
import { Text } from 'react-native';
import { DatePicker } from 'patine-ui';
import type { DateRange } from 'patine-ui';

export default function Example() {
  const [range, setRange] = useState<DateRange>({ start: null, end: null });
  return (
    <>
      <Text style={{ textAlign: 'center', marginBottom: 4, color: '#6E685E' }}>
        Stay 2 – 7 nights
      </Text>
      <DatePicker
        mode="range"
        value={range}
        onValueChange={setRange}
        minDate={new Date()}
        minRangeDays={2}
        maxRangeDays={7}
        allowSingleDayRange={false}
      />
    </>
  );
}
```

### Presets

`presets` adds a row of chips above the days, and each one picks a whole range in one tap: the shortcuts of a report or a filter screen. `getRangePresets()` returns the usual ones, counted back from today: Today, Yesterday, Last 7 days, Last 30 days, This month and Last month. The chip that matches the range shows selected, so picking the same days by hand selects it too.

`presetsProps` takes any [`ChipGroup`](./chip-group#props) prop for the row except `items`, `value`, `onValueChange` and `isEqual`, which come from the presets and the range. Here `showArrows` adds ‹ › buttons that scroll the chips, floating over the edges with `arrowPosition: 'overlay'`:

```tsx live
import { useState } from 'react';
import { DatePicker, getRangePresets } from 'patine-ui';
import type { DateRange } from 'patine-ui';

const presets = getRangePresets();

export default function Example() {
  const [range, setRange] = useState<DateRange>({ start: null, end: null });
  return (
    <DatePicker
      mode="range"
      value={range}
      onValueChange={setRange}
      presets={presets}
      presetsProps={{
        variant: 'chips',
        showArrows: true,
        arrowPosition: 'overlay',
        accessibilityLabel: 'Quick date ranges',
      }}
      maxDate={new Date()}
    />
  );
}
```

`variant: 'segmented'` puts a few presets on a track instead, and `renderItem` and `styles` draw your own chip.

A preset the calendar wouldn't let you pick is disabled: one outside `minDate` / `maxDate`, one that crosses a disabled day or breaks `minRangeDays`, `maxRangeDays` or `allowSingleDayRange`. Picking one shows the month its range starts in.

Write your own as `{ label, start, end }`, such as the next weekend, or to label them in another language:

```tsx
const presets = [
  { label: 'This weekend', start: saturday, end: addDays(saturday, 1) },
  ...getRangePresets().filter((preset) => preset.label !== 'Yesterday'),
];
```

`DatePickerSheet` and `DatePickerField` take `presets` and `presetsProps` too.

### Range styling

```tsx live
import { useState } from 'react';
import { DatePicker, addDays } from 'patine-ui';
import type { DateRange } from 'patine-ui';

export default function Example() {
  const t = new Date();
  const [range, setRange] = useState<DateRange>({
    start: addDays(t, 2),
    end: addDays(t, 6),
  });
  return (
    <DatePicker
      mode="range"
      value={range}
      onValueChange={setRange}
      theme={{ colors: { primary: '#E11D48', primaryMuted: '#FFE4E6' } }}
      styles={{
        selectedDay: { borderRadius: 10 },
        rangeBand: { borderRadius: 0 },
      }}
    />
  );
}
```

## Multiple

Tap days to toggle them. `onValueChange` always receives the dates **sorted ascending**. With `maxSelections`, further taps on unselected days are ignored once the limit is reached (deselecting still works).

```tsx live
import { useState } from 'react';
import { Text } from 'react-native';
import { DatePicker, formatDate } from 'patine-ui';

export default function Example() {
  const [dates, setDates] = useState<Date[]>([]);
  return (
    <>
      <DatePicker
        mode="multiple"
        value={dates}
        onValueChange={setDates}
        maxSelections={5}
        minDate={new Date()}
      />
      <Text style={{ textAlign: 'center', color: '#6E685E' }}>
        {dates.length
          ? dates
              .map((d) =>
                formatDate(d, undefined, { day: 'numeric', month: 'short' })
              )
              .join(', ')
          : 'Pick up to 5 days'}
      </Text>
    </>
  );
}
```

## Multiple ranges

`mode="ranges"` picks several date ranges, e.g. blackout periods or trip legs. Each range is built with two taps, just like range mode. Tapping any day of a finished range removes it. Ranges never overlap, and `onValueChange` receives them **sorted by start**. The range rules (`minRangeDays`, `maxRangeDays`, `allowSingleDayRange`) apply to each range. With `maxRanges`, taps that would start another range are ignored once the limit is reached.

```tsx live
import { useState } from 'react';
import { Text } from 'react-native';
import { DatePicker, formatDate } from 'patine-ui';
import type { DateRange } from 'patine-ui';

export default function Example() {
  const [ranges, setRanges] = useState<DateRange[]>([]);
  const short = (d: Date | null) =>
    d ? formatDate(d, undefined, { day: 'numeric', month: 'short' }) : '…';
  return (
    <>
      <DatePicker
        mode="ranges"
        value={ranges}
        onValueChange={setRanges}
        maxRanges={3}
        minDate={new Date()}
      />
      <Text style={{ textAlign: 'center', color: '#6E685E' }}>
        {ranges.length
          ? ranges.map((r) => `${short(r.start)} – ${short(r.end)}`).join(', ')
          : 'Pick up to 3 ranges'}
      </Text>
    </>
  );
}
```

## Uncontrolled

```tsx
<DatePicker mode="range" defaultValue={{ start: new Date(), end: null }} onValueChange={(r) => console.log(r)} />
<DatePicker mode="multiple" defaultValue={[]} onValueChange={(d) => console.log(d)} />
```

## In a sheet

`DatePickerSheet` disables **Done** until the range is complete (both `start` and `end`). In ranges mode, it waits until no range is half-picked.

```tsx
<DatePickerSheet
  open={open}
  onOpenChange={setOpen}
  title="Your stay"
  mode="range"
  value={range}
  onConfirm={setRange}
  minDate={new Date()}
  minRangeDays={1}
/>
```

→ [DatePickerSheet](./picker-sheets#datepickersheet)

## In a form field

`DatePickerField` takes the same props without `visible`, and shows the confirmed range (`Oct 5, 2026 – Oct 9, 2026`) or dates in the field. Switch `presentation` in the panel: `auto` opens a dropdown under the field on the web and a bottom sheet on iOS and Android.

→ [Picker fields](./picker-fields)

## Working with ranges

The [date utilities](../api/date-utils) make common range checks one-liners:

```ts
import { isBetweenDays, isSameDay, compareDay } from 'patine-ui';

const nights = Math.round((range.end!.getTime() - range.start!.getTime()) / 86_400_000);
const includesToday = isSameDay(range.start, new Date()) || isBetweenDays(new Date(), range.start, range.end);
const isFuture = compareDay(range.start!, new Date()) > 0;
```

## Props

All [calendar props](./date-picker#calendar) apply. Mode-specific props:

| Prop | Mode | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `presets` | `range` | `DateRangePreset[]` | — | Chips above the days that pick a whole range, such as `getRangePresets()`. A preset the rules wouldn't allow is disabled. |
| `presetsProps` | `range` | `RangePresetsListProps` | — | [`ChipGroup`](./chip-group#props) props for the presets row, except `items`, `value`, `onValueChange` and `isEqual`. Default: chips. |
| `minRangeDays` | `range`, `ranges` | `number` | — | Minimum nights (end − start in days). Shorter second taps are ignored. |
| `maxRangeDays` | `range`, `ranges` | `number` | — | Maximum nights. Longer second taps start a new range. |
| `allowSingleDayRange` | `range`, `ranges` | `boolean` | `true` | Allow `start === end`. |
| `maxSelections` | `multiple` | `number` | — | Maximum number of selected days. |
| `maxRanges` | `ranges` | `number` | — | Maximum number of ranges. |

## Related

- [DatePicker](./date-picker): the calendar these modes build on
- [Picker sheets](./picker-sheets#datepickersheet): a range in a sheet with Cancel / Done
- [Hotel booking example](/examples/hotel-booking): check-in and check-out with prices on the days
