Skip to main content

Selection Modes

The mode prop determines the selection mode. DayPicker offers predefined rules for date selection.

  • Single mode: Allows the selection of a single date.
  • Multiple mode: Allows the selection of multiple individual dates.
  • Range mode: Allows the selection of a continuous range of dates.

Customizing Selections

To customize the behavior of a selection mode, use the selected and onSelect props to handle the selection event and update the selected dates according to your application's requirements:

import { useState } from "react";

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

export function App() {
const [selected, setSelected] = useState<Date[] | undefined>();
const handleSelect = (newSelected) => {
// Update the selected dates
setSelected(newSelected);
};
return (
<DayPicker mode="multiple" selected={selected} onSelect={handleSelect} />
);
}

You can also set the selection mode to default and implement your own mode using modifiers and onDayClick. For more information, read the Custom Selections guide.