Calendar

Designer doc
A utility component for calendar display and input.

Example

Basic usage
View code
You can also pass in startOfWeek prop to control which day to show as the start of the week. By default, Sunday will be shown as the first day. In below example, Monday is shown as the first day instead.
View code
Coral also exposes DateView, MonthView, and YearView. These are, in contrast, presentation and fully-controlled components - these components do not include selections or have any states. Built on top of LayoutGrid. These components are accessible, customizable, and used in Calendar.
Render dates
View code
Customizing DateView cells
Note that when you’re customizing the cells, you have full control of what being rendered. However, this comes with a caveat - you shouldn’t return null in renderDate or renderDay because it will shift the cells.
If you only want to customize a certain cell, you can return the rest of the cells with second parameter, which is the defaultCell. In some cases, you are recommended to use React first-class utility function cloneElement to add some props to the defaultCell.
View code
range in DateCell
DateCell accepts range prop with schema { start: boolean, end: boolean }. This props determines the corner rounding because this component doesn’t handle the rounding corner itself.
View code
Using createDateRange
If you find it troublesome to keep handling ranges, you can use utility function createDateRange(start, end) which return getRange function. Note that the range is inclusive.
This API may look strange, but you can find some references on popular libraries like downshift, react-dropzone, react-use-gesture. It’s normally known as prop getters.
View code
Render months
View code
Customizing MonthView cells
Similar to createDateRange, you can use createMonthRange for more accurate calculation.
View code
Render years
Using YearView, you need to pass decade prop and it must be multiples of 10.
View code
Customizing YearView cells
Similar to createDateRange, you can use createYearRange for more accurate calculation.
View code

Accessibility

In Calendar, header of each view handles Arrow Left and Right to navigate between months, years, or decades. Pressing Enter on it will change the mode one level above. These components are also attributed with aria-live="polite" to inform the user when the months, years, or decades have changed.
For each view, you can press Arrow Up, Down, Left, Right to navigate through dates like a grid. Each cell is also aria-labeled with the full text of each date (e.g. Monday, 1 January 1999).

Relevant components

References

API

Calendar
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
dateDayjs
dateFooterReactNode
dateHeaderReactNode
dateViewPropsViewProps
immediateboolean
initialDateDayjsdayjs()
initialModeCalendarModesdate
modeCalendarModes
monthFooterReactNode
monthHeaderReactNode
monthViewPropsViewProps
onDateChange(date: Dayjs) => void
onModeChange(mode: CalendarModes) => void
onPreviousModeChange(mode: CalendarModes) => void
previousModeCalendarModes
renderDate(props: RenderCalendarDateOptions, defaultCell: ReactElement<CalendarDateCellProps, any>) => ReactNode
renderDay(props: RenderDayOptions, defaultCell: ReactElement<RenderDayOptions, any>) => ReactNode
renderMonth(props: RenderCalendarMonthOptions, defaultCell: ReactElement<CalendarMonthCellProps, any>) => ReactNode
renderYear(props: RenderCalendarYearOptions, defaultCell: ReactElement<CalendarYearCellProps, any>) => ReactNode
startOfWeekDay0
Accepts numbers from 0 (Sunday) to 6 (Saturday).
todayDayjsdayjs()
yearFooterReactNode
yearHeaderReactNode
yearViewPropsViewProps
DateCell
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
dateDayjs
disableGridboolean
disabledboolean
Equivalent to button's disabled property.
keyboardClickKeysstring[]
onBlurFocusEventHandler<HTMLDivElement>
onClickMouseEventHandler<HTMLDivElement>
onGridFocus() => void
onKeyDownKeyboardEventHandler<HTMLDivElement>
onKeyUpKeyboardEventHandler<HTMLDivElement>
onMouseDownMouseEventHandler<HTMLDivElement>
onMouseLeaveMouseEventHandler<HTMLDivElement>
onMouseUpMouseEventHandler<HTMLDivElement>
onReleaseEventHandler<SyntheticEvent<HTMLDivElement, Event>>
Callback that's triggered after click i.e. mouseup and keyup of enter or space.
onTouchEndTouchEventHandler<HTMLDivElement>
onTouchStartTouchEventHandler<HTMLDivElement>
preventScrollboolean
rangeRange
startOfWeekDay0
todayDayjsdayjs()
variantCellVariants
DateView
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
monthnumber
renderDate(props: RenderDateOptions, defaultCell: ReactElement<RenderDateOptions, any>) => ReactNode(props: RenderDateOptions) => <DateCell {...props} />
renderDay(props: RenderDayOptions, defaultCell: ReactElement<RenderDayOptions, any>) => ReactNode({ day }: RenderDayOptions) => <DayCell day={day} />
startOfWeekDay
yearnumber
DayCell
Prop nameTypeDefaultDescription
asvoid | WebTarget
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
forwardedAsvoid | WebTarget
themeDefaultTheme
MonthCell
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
disableGridboolean
disabledboolean
Equivalent to button's disabled property.
keyboardClickKeysstring[]
monthDayjs
onBlurFocusEventHandler<HTMLDivElement>
onClickMouseEventHandler<HTMLDivElement>
onGridFocus() => void
onKeyDownKeyboardEventHandler<HTMLDivElement>
onKeyUpKeyboardEventHandler<HTMLDivElement>
onMouseDownMouseEventHandler<HTMLDivElement>
onMouseLeaveMouseEventHandler<HTMLDivElement>
onMouseUpMouseEventHandler<HTMLDivElement>
onReleaseEventHandler<SyntheticEvent<HTMLDivElement, Event>>
Callback that's triggered after click i.e. mouseup and keyup of enter or space.
onTouchEndTouchEventHandler<HTMLDivElement>
onTouchStartTouchEventHandler<HTMLDivElement>
preventScrollboolean
rangeRange
todayDayjsdayjs()
variantCellVariants
MonthView
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
renderMonth(props: RenderMonthOptions, defaultCell: ReactElement<CalendarMonthCellProps, any>) => ReactNode(props: RenderMonthOptions) => <MonthCell {...props} />
yearnumber
YearCell
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
disableGridboolean
disabledboolean
Equivalent to button's disabled property.
keyboardClickKeysstring[]
onBlurFocusEventHandler<HTMLDivElement>
onClickMouseEventHandler<HTMLDivElement>
onGridFocus() => void
onKeyDownKeyboardEventHandler<HTMLDivElement>
onKeyUpKeyboardEventHandler<HTMLDivElement>
onMouseDownMouseEventHandler<HTMLDivElement>
onMouseLeaveMouseEventHandler<HTMLDivElement>
onMouseUpMouseEventHandler<HTMLDivElement>
onReleaseEventHandler<SyntheticEvent<HTMLDivElement, Event>>
Callback that's triggered after click i.e. mouseup and keyup of enter or space.
onTouchEndTouchEventHandler<HTMLDivElement>
onTouchStartTouchEventHandler<HTMLDivElement>
preventScrollboolean
rangeRange
todayDayjsdayjs()
typeYearTypes
variantCellVariants
yearDayjs
YearView
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
decadenumber
renderYear(props: RenderYearOptions, defaultCell: ReactElement<CalendarYearCellProps, any>) => ReactNode(props: RenderYearOptions) => <YearCell {...props} />
    Example
    Example
    Basic usage
    Basic usage
    Render dates
    Render dates
    Render months
    Render months
    Render years
    Render years
    Accessibility
    Accessibility
    Relevant components
    Relevant components
    References
    References
    API
    API
    Calendar
    Calendar
    DateCell
    DateCell
    DateView
    DateView
    DayCell
    DayCell
    MonthCell
    MonthCell
    MonthView
    MonthView
    YearCell
    YearCell
    YearView
    YearView
Coral is a thoroughly developed design system widely adopted by developers and designers for creating beautiful and user-friendly Sea internal products.

Copyright © 2018-2025 Sea Labs