Skip to main content

Single Mode

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

<DayPicker mode="single" />

Props

Prop NameTypeDescription
selectedDate | undefined (MDN)The selected date.
onSelectOnSelectHandler<Date | undefined>Event callback when a date is selected.
requiredbooleanMake the selection required.

Controlled Selections

Use the selected and onSelect props to control the selected date:

export function App() {
const [selected, setSelected] = React.useState<Date | undefined>();
return <DayPicker mode="single" selected={selected} onSelect={setSelected} />;
}

Required Selection

By setting the required prop, DayPicker ensures that the user cannot unselect the selected date.

<DayPicker mode="single" required />