Skip to main content
Version: 8.10.1

Selection Modes

DayPicker comes with some predefined rules for selecting days:

To make days selectable, set the mode prop. Disallow the selection of specific days by using the disabled prop.

Single Mode

When the mode prop is set to "single", only one day can be selected at a time.

<DayPicker mode="single" />

The following code snippet will render a date picker with a single selected date. When a day is clicked, the selectedDate state is updated.

import { useState } from "react";

import { DayPicker } from "react-day-picker";

export function App() {
const initiallySelectedDate = new Date();
const [selectedDate, setSelectedDate] = useState(initiallySelectedDate);
return (
<DayPicker
mode="single"
selected={selectedDate}
onSelect={setSelectedDate}
/>
);
}

Required Selection

By setting the required prop, DayPicker won't allow the user to unselect the selected date.

<DayPicker
mode="single"
selected={selectedDate}
onSelect={setSelectedDate}
required // A date must be selected
/>

Multiple Mode

By setting the mode prop to "multiple", DayPicker allows selecting multiple days.

<DayPicker mode="multiple" />
import { useState } from "react";

import { DayPicker } from "react-day-picker";

export function App() {
const initiallySelectedDates = [new Date(), addDays(new Date(), 1)];

const [selectedDates, setSelectedDates] = useState<Date[]>([]);

return (
<DayPicker
mode="multiple"
selected={selectedDates}
onSelect={(dates) => setSelectedDates(dates || [])}
/>
);
}

Min and Max Dates

Use the min and max props to limit the number of selectable dates.

import { useState } from "react";

import { DayPicker } from "react-day-picker";

export function App() {
const initiallySelectedDates = [new Date(), addDays(new Date(), 1)];
const [selected, setSelected] = useState(initiallySelectedDates);
return (
<DayPicker
mode="multiple"
min={2} // At least 2 dates must be selected
max={5} // Maximum 5 dates can be selected
selected={selected}
onSelect={(dates) => setSelected(dates ?? [])}
/>
);
}

Range Mode

When the mode prop is set to "range", DayPicker allows selecting a continuous range of dates.

<DayPicker mode="range" />
import { useState } from "react";

import { addDays } from "date-fns";
import { DateRange, DayPicker } from "react-day-picker";

export function Range() {
const initialRange: DateRange = {
from: new Date(),
to: addDays(new Date(), 4)
};

const [range, setRange] = useState<DateRange | undefined>(initialRange);

return <DayPicker mode="range" selected={range} onSelect={setRange} />;
}

Min and Max Dates

Also in range mode, you can set the min and max props to limit the number of selectable dates.

import { useState } from "react";

import { DateRange, DayPicker } from "react-day-picker";

export function RangeMinMax() {
const [range, setRange] = useState<DateRange | undefined>();

return (
<DayPicker
defaultMonth={new Date(2022, 8)}
mode="range"
min={3}
max={6}
selected={range}
onSelect={setRange}
/>
);
}

Shift Key

The following DayPicker requires the Shift key to select a range of dates. See examples/RangeShiftKey.tsx for the full source code.

Disabling Dates

To disable specific days, use the disabled prop. The prop accepts a Matcher or an array of matchers that can be used to make some days not selectable.

<DayPicker
mode="single"
disabled={{ daysOfWeek: [0, 6] }} // Disable Sundays and Saturdays
/>

Custom Mode