shadcn.io is not affiliated with official shadcn/ui
Calendar examples · Dialog
Calendar with Month and Year Selector in Dialog for React
A button that opens a dialog with a calendar navigated by month and year dropdowns.
The month and year calendar inside a Dialog: a Select Date button opens it, and two selects at the top move the month shown. The dropdowns open above the dialog.
Preview
Installation
FAQ
How do the month and year dropdowns work?
captionLayout="dropdown" and hideNavigation replace the previous and next buttons with month and year dropdowns. components.Dropdown renders each as a Select, and month with onMonthChange tracks the visible month apart from selected.
Where is the dialog in this file?
CalendarDropdown returns a Dialog whose content is the month or year Select. The Calendar itself stays on the page, with captionLayout="dropdown" and hideNavigation.
How do I read the selected date?
mode="single" makes selected one date and onSelect the setter. This demo stores that date in state, starting from new Date().
Which years are in the year dropdown?
The year Select lists the options the calendar passes into Dropdown. A SelectItem sets disabled from option.disabled, so a year the calendar turns off stays disabled.
Related
- Calendar with Month and Year SelectorA calendar with month and year dropdowns
- Calendar with Range in DialogA button that opens a dialog with a
- Standard DialogA share dialog with a read-only link, a
- Calendar with Date and Time in DialogA button that opens a dialog with a
- Date Picker with RangeA date range picker that shows two months
- Calendar as Appointment Picker in DialogA Book Appointment button that opens a