Calendar
Usage
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Controlled month
Control month that is currently displayed with month
and onMonthChange
props:
Alternatively, set initialMonth
prop to set initial month in uncontrolled component:
Level change
Calendar supports three levels: date, month and year. User can access next level by clicking label between next/previous controls.
To disable that, set allowLevelChange
prop to false:
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Localization
All @mantine/dates components are built with dayjs library.
Default locale is en
, to change this follow dayjs localization guide:
Then set locale
prop in component:
Пн | Вт | Ср | Чт | Пт | Сб | Вс |
---|---|---|---|---|---|---|
First day of the week
Change first day of week with firstDayOfWeek
prop. It accepts either sunday
or monday
as values:
Su | Mo | Tu | We | Th | Fr | Sa |
---|---|---|---|---|---|---|
Multiple months
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Label format
By default, Calendar will display dates in human-readable format.
To change that, provide dayjs format string to the labelFormat
prop:
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Min and max dates
Set minDate
and maxDate
props to define minimum and maximum possible dates.
Dates which are not included in available interval will be disabled:
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Exclude dates
To exclude dates set excludeDates
prop with function that receives date as an argument and returns
true
if date should be disabled. For example, to disable weekends, check if date day is 0 or 6:
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Add styles to days
You can apply styles to any day with dayStyle
or dayClassName
callbacks.
Both functions receive two arguments:
date
– date object which is used to render day componentmodifiers
– modifiers that are applied to the day component
Modifiers
Styles based on date
dayStyle
callback allows you to add inline styles to days. Function must return either styles object or null.
In this example, we will add red background to each Friday 13th based on date (first argument):
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Styles based on modifiers
dayClassName
callback allows you to add className to days. Function must return either className string or null.
In this example, we will hide all outside dates and change color of weekends based on modifiers (second argument):
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|
Customize with styles API
To customize any part of the calendar use Styles API:
Mo | Tu | We | Th | Fr | Sa | Su |
---|---|---|---|---|---|---|