shadcn.io is not affiliated with official shadcn/ui
Calendar examples · Dialog
Calendar with Date and Time in Dialog for React
A button that opens a dialog with a calendar and a time input for picking a date and a time.
The date and time calendar inside a Dialog: a Select Date & Time button opens it, with the month on top and the Time field below. Use it when scheduling is one step of a larger form.
Preview
Installation
FAQ
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().
How is the time entered?
The time is an Input with type="time" inside a Field. FieldLabel reads Time, value starts at 12:00, and onChange stores event.target.value in its own state. Changing the time leaves the calendar date as it is.
Are the date and the time one value?
date and time are two pieces of state. The calendar updates date, and the input updates time. This demo keeps the hours and minutes on the time state.
How is the input attached to the calendar?
Inside the dialog, a divide-y stack with overflow-hidden, rounded-md and border holds the calendar, then the field. The field has p-4.
Related
- Calendar with Date and TimeA calendar with a time input under it for
- Calendar as Appointment Picker in DialogA Book Appointment button that opens a
- Standard DialogA share dialog with a read-only link, a
- Calendar with Range in DialogA button that opens a dialog with a
- Input with LabelA text input with a label above it
- Required LabelA label with a destructive asterisk that