Calendar

A month grid to pick a day with the mouse or the keyboard. DatePicker uses it, and you can use it alone when the calendar should always be visible.

In Next.js 16 with cacheComponents on, wrap a Calendar that is always visible in <Suspense>. It reads today's date while it renders, and Next does not prerender that. A DatePicker does not need it, because its calendar opens on a click.

General

Pass the selected day with value and listen to onChange.

Min and max

Days outside the range are disabled and the keyboard does not go there.

Locale and first day of the week

locale sets the names of the month and of the weekdays, and weekStartsOn the first column (0 is Sunday).

Multiple

With mode set to multiple each click adds or removes a day, and value is an array. Use maxSelected to limit how many.

Range

With mode set to range the first click sets the start and the second the end. value is [start, end].

Disable dates

shouldDisableDate receives each day and returns true to block it, like weekends or holidays.

Outside days and week numbers

showOutsideDays fills the grid with days of the neighbor months, and showWeekNumbers adds the ISO week of each row.

Several months

numberOfMonths shows the months side by side. A range can cross from one to the next, and the days of the neighbor months are hidden.

APIs

Calendar.Props

AttributeDescriptionTypeAccepted valuesDefault
valueselected day, days or range, to control the componentDate / null, Date[] or [Date, Date]--
onChangecalled with what the user picked, in the shape of value(value) => void--
minfirst day that can be pickedDate--
maxlast day that can be pickedDate--
localelanguage of the month and weekday namesstringany Intl localeen-US
weekStartsOnfirst day of the week, 0 is Sundaynumber0 to 60
modehow many days can be pickedstring'single', 'multiple', 'range'single
maxSelectedmost days in multiple modenumber--
shouldDisableDatedisable the days where it returns true(date: Date) => boolean--
showOutsideDaysshow days of the neighbor monthsboolean-false
numberOfMonthsmonths shown side by side; hides the neighbor days if more than onenumber-1
showWeekNumbersshow the ISO week of each rowboolean-false
monthvisible month, to control itDate--
defaultMonthvisible month at the startDate-the selected day
onMonthChangecalled with the first day of the new month(month: Date) => void--
weekLabelname of the week number columnstring-Week
autoFocusmove the focus to the day when it is shownboolean-false
previousLabelname of the previous month buttonstring-Previous month
nextLabelname of the next month buttonstring-Next month
...native propsHTMLAttributes'id', 'className', ...-

Ref

The ref points at the root element.

Accessibility

The days are a grid named by the month, with a single tab stop on the focused day. The selected day has aria-selected and today has aria-current="date".

KeyAction
Arrow keysMove by one day, or one week
Home and EndGo to the first and to the last day of the week
Page Up and Page DownGo to the previous and to the next month
Shift and Page Up or DownGo to the previous and to the next year
Enter and SpacePick the day
Edit this page on GitHub