Date Picker
Use the date picker component to create date pickers that match your design.
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Alternative selection modes
Range
Set the prop mode
to range
to enable the range selection mode.
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Multiple
Set the prop mode
to multiple
to enable the multiple selection mode.
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Controlled state
The following example uses a state value to keep track of the date range and renders it in a popover.
Number of columns
The date picker can be configured to show a different number of columns. Using the numberOfColumns
prop. The following example shows a date picker with 2 columns.
This demo is only available on desktop. Please use a screen with a width of 768px or more to view the demo.
Min and max dates
You can set the minimum and maximum dates that can be selected using the minDate
and maxDate
props.
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
The size prop
The size
prop can be used to change the size of the date picker. Sizes xs, sm, md, lg, and xl are available.
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Change the month and year item formats
Using the monthsListFormat
and yearsListFormat
props, you can change the format of the month and year items.
Refer to the dayjs documentation for more information on the formatting options.
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Using the date picker inside a @shadcn/ui
form
The date picker can be used inside a @shadcn/ui
form. The following example shows a date picker inside a form.
Selecting a single date in a range
By default clicking a date twice will deselect it. If you want to allow your users to select a single date use the allowSingleDateInRange
prop.
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Changing the default date
You can set the default date using the defaultDate
prop. The calendar will automatically jump to this date.
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Localization
The date picker can be localized by passing a locale string to the locale
prop. The following example shows a date picker with a custom locale.
Locale prop
Use the locale
prop to set the locale of the date picker.
lu | ma | mi | ju | vi | sá | do |
---|---|---|---|---|---|---|
First day of week prop
Use the firstDayOfWeek
prop to set the first day of the week.
do | lu | ma | mi | ju | vi | sá |
---|---|---|---|---|---|---|