DatePicker
Inline date, multiple dates and dates range picker
Import
Source
Docs
Package
Usage
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Allow deselect
Set allowDeselect
to allow user to deselect current selected date by clicking on it.
allowDeselect
is disregarded when type
prop is range
or multiple
. When date is
deselected onChange
is called with null
.
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Multiple dates
Set type="multiple"
to allow user to pick multiple dates:
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Dates range
Set type="range"
to allow user to pick dates range:
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Single date in range
By default, it is not allowed to select single date as range – when user clicks the same date second time it is deselected.
To change this behavior set allowSingleDateInRange
prop. allowSingleDateInRange
is ignored when
type
prop is not range
.
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Default date
Use defaultDate
prop to set date value that will be used to determine which year should be displayed initially.
For example to display 2015 February
month set defaultDate={new Date(2015, 1)}
. If value is not specified,
then defaultDate
will use new Date()
. Day, minutes and seconds are ignored in provided date object, only year and month data is used –
you can specify any date value.
Note that if you set date
prop, then defaultDate
value will be ignored.
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Controlled date
Set date
, and onDateChange
props to make currently displayed month, year and decade controlled.
By doing so, you can customize date picking experience, for example, when user selects first date in range,
you can add one month to the current date value:
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Default level
Set defaultLevel
prop to configure initial level that will be displayed:
Hide outside dates
Set hideOutsideDates
prop to remove all dates that do not belong to the current month:
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Display week numbers
Set withWeekNumbers
prop to display week numbers:
# | Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|---|
48 | |||||||
49 | |||||||
50 | |||||||
51 | |||||||
52 | |||||||
1 |
First day of week
Set firstDayOfWeek
prop to configure first day of week. The prop accepts number from 0 to 6,
where 0 is Sunday and 6 is Saturday. Default value is 1 – Monday. You can also configure this option
for all components with DatesProvider.
Su | Mo | Tu | We | Th | Fr | Sa |
---|---|---|---|---|---|---|
Sa | Su | Mo | Tu | We | Th | Fr |
---|---|---|---|---|---|---|
Hide weekdays
Set hideWeekdays
prop to hide weekdays names:
Weekend days
Use weekendDays
prop to configure weekend days. The prop accepts an array of numbers from 0 to 6,
where 0 is Sunday and 6 is Saturday. Default value is [0, 6]
– Saturday and Sunday. You can also configure this option
for all components with DatesProvider.
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Render day function
You can customize day rendering with renderDay
prop. For example, it can be used to add
Indicator to certain days.
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Min and max date
Set minDate
and maxDate
props to define min and max dates. If previous/next page is not available
then corresponding control will be disabled.
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Add props to year and month control
You can add props to year, month and day controls with getYearControlProps
, getMonthControlProps
and getDayProps
functions. All functions accept date as single argument,
props returned from the function will be added to year/month/day control. For example, it can be used to disable specific
control or add styles:
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Exclude dates
To disable specific dates use excludeDate
prop.
It accepts function that takes date as argument and returns boolean value – if true
is returned, date will be disabled.
Example of disabling all dates that are not Fridays:
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Number of columns
Set numberOfColumns
prop to define number of pickers that will be rendered side by side:
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Demo is not available on small screens. Make your screen larger to see the demo.
Max level
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Size
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Change year and months controls format
Use yearsListFormat
and monthsListFormat
props to change dayjs format of year/month controls:
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Change label format
Use decadeLabelFormat
, yearLabelFormat
and monthLabelFormat
props to change dayjs format of decade/year label:
Localization
Usually it is better to specify @mantine/dates
package locale in DatesProvider,
but you can also override locale per component:
пн | вт | ср | чт | пт | сб | вс |
---|---|---|---|---|---|---|
Accessibility
Aria labels
Set ariaLabels
prop to specify aria-label
attributes for next/previous controls:
Year/month control aria-label
Use getYearControlProps
/getMonthControlProps
/getDayProps
to customize aria-label
attribute:
Keyboard interactions
Note that the following events will only trigger if focus is on date control.
Key | Description |
---|---|
ArrowRight | Focuses next non-disabled date |
ArrowLeft | Focuses previous non-disabled date |
ArrowDown | Focuses next non-disabled date in the same column |
ArrowUp | Focuses previous non-disabled date in the same column |