Command Palette

Search for a command to run...

Calendar

A date field component that allows users to select dates and date ranges.

SuMoTuWeThFrSa

Installation

npm i react-day-picker date-fns

Usage

1 2 3 4 5 6 7 8 9 10 11 12 13 14 import { Calendar } from "@/components/ui/calendar" export function CalendarDemo() { const [date, setDate] = React.useState<Date | undefined>(new Date()) return ( <Calendar mode="single" selected={date} onSelect={setDate} className="rounded-md border" /> ) }

Examples

Range Selection

SuMoTuWeThFrSa

Disabled Dates

Disabled Date Range

SuMoTuWeThFrSa

Props

NameTypeDescription
mode"single" | "range" | "multiple"The selection mode of the calendar.
selectedDate | {from: Date, to: Date} | Date[] | undefinedThe selected date or range.
onSelectfunctionCallback function when a date is selected.
disabledDateRange | Date[] | DisabledDaysDays that are disabled and cannot be selected.
initialFocusbooleanWhether to focus the calendar on initial render.
numberOfMonthsnumberNumber of months to display.
fromMonthDateThe minimum month to display.
toMonthDateThe maximum month to display.
showOutsideDaysbooleanWhether to show days from the previous and next months.