Container for displaying data in calendar form.
When data is in the form of dates, such as schedules, timetables, prices calendar, lunar calendar. This component also supports Year/Month switch.
Common props ref:Common props
Note: Part of the Calendar's locale is read from value
. So, please set the locale of dayjs
correctly.
// The default locale is en-US, if you want to use other locale, just set locale in entry file globally.// import dayjs from 'dayjs';// import 'dayjs/locale/zh-cn';// dayjs.locale('zh-cn');<CalendardateCellRender={dateCellRender}monthCellRender={monthCellRender}onPanelChange={onPanelChange}onSelect={onSelect}/>
Property | Description | Type | Default | Version |
---|---|---|---|---|
dateCellRender | Customize the display of the date cell, the returned content will be appended to the cell | function(date: Dayjs): ReactNode | - | |
dateFullCellRender | Customize the display of the date cell, the returned content will override the cell | function(date: Dayjs): ReactNode | - | |
defaultValue | The date selected by default | dayjs | - | |
disabledDate | Function that specifies the dates that cannot be selected, currentDate is same dayjs object as value prop which you shouldn't mutate it](https://github.com/ant-design/ant-design/issues/30987) | (currentDate: Dayjs) => boolean | - | |
fullscreen | Whether to display in full-screen | boolean | true | |
headerRender | Render custom header in panel | function(object:{value: Dayjs, type: string, onChange: f(), onTypeChange: f()}) | - | |
locale | The calendar's locale | object | (default) | |
mode | The display mode of the calendar | month | year | month | |
monthCellRender | Customize the display of the month cell, the returned content will be appended to the cell | function(date: Dayjs): ReactNode | - | |
monthFullCellRender | Customize the display of the month cell, the returned content will override the cell | function(date: Dayjs): ReactNode | - | |
validRange | To set valid range | [dayjs, dayjs] | - | |
value | The current selected date | dayjs | - | |
onChange | Callback for when date changes | function(date: Dayjs) | - | |
onPanelChange | Callback for when panel changes | function(date: Dayjs, mode: string) | - | |
onSelect | Callback for when a date is selected, include source info | function(date: Dayjs, info: { source: 'year' | 'month' | 'date' | 'customize' }) | - | info : 5.6.0 |
Token Name | Description | Type | Default Value |
---|---|---|---|
fullBg | Background color of full calendar | string | #ffffff |
fullPanelBg | Background color of full calendar panel | string | #ffffff |
itemActiveBg | Background color of selected date item | string | #e6f4ff |
miniContentHeight | Height of mini calendar content | number | 256 |
monthControlWidth | Width of month select | number | 70 |
yearControlWidth | Width of year select | number | 80 |
See How to set locale for date-related components
See FAQ Date-related-components-locale-is-not-working?
onSelect
provide info.source
to help on this:
<CalendaronSelect={(date, { source }) => {if (source === 'date') {console.log('Panel Select:', source);}}}/>
Su | Mo | Tu | We | Th | Fr | Sa |
---|---|---|---|---|---|---|
27 | 28 | 29 | 30 | 31 | 01 | 02 |
03 | 04 | 05 | 06 | 07 | 08 | 09 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
01 | 02 | 03 | 04 | 05 | 06 | 07 |
Su | Mo | Tu | We | Th | Fr | Sa |
---|---|---|---|---|---|---|
27 | 28 | 29 | 30 | 31 | 01 | 02 |
03 | 04 | 05 | 06 | 07 | 08
| 09 |
10
| 11 | 12 | 13 | 14 | 15
| 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
01 | 02 | 03 | 04 | 05 | 06 | 07 |
Su | Mo | Tu | We | Th | Fr | Sa |
---|---|---|---|---|---|---|
27 | 28 | 29 | 30 | 31 | 01 | 02 |
03 | 04 | 05 | 06 | 07 | 08 | 09 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
01 | 02 | 03 | 04 | 05 | 06 | 07 |
Su | Mo | Tu | We | Th | Fr | Sa |
---|---|---|---|---|---|---|
01 | 02 | 03 | 04 | 05 | 06 | 07 |
08 | 09 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 01 | 02 | 03 | 04 |
05 | 06 | 07 | 08 | 09 | 10 | 11 |
Su | Mo | Tu | We | Th | Fr | Sa |
---|---|---|---|---|---|---|
27 十二 | 28 十三 | 29 十四 | 30 十五 | 31 十六 | 1 十七 | 2 十八 |
3 十九 | 4 二十 | 5 廿一 | 6 廿二 | 7 廿三 | 8 白露 | 9 廿五 |
10 廿六 | 11 廿七 | 12 廿八 | 13 廿九 | 14 三十 | 15 初一 | 16 初二 |
17 初三 | 18 初四 | 19 初五 | 20 初六 | 21 初七 | 22 初八 | 23 秋分 |
24 初十 | 25 十一 | 26 十二 | 27 十三 | 28 十四 | 29 中秋节 | 30 十六 |
1 国庆节 | 2 十八 | 3 十九 | 4 二十 | 5 廿一 | 6 廿二 | 7 廿三 |
Su | Mo | Tu | We | Th | Fr | Sa |
---|---|---|---|---|---|---|
27 | 28 | 29 | 30 | 31 | 01 | 02 |
03 | 04 | 05 | 06 | 07 | 08 | 09 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
01 | 02 | 03 | 04 | 05 | 06 | 07 |