Calendar
An easily stylable calendar component.
View as Markdown| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
Anatomy
Import the component and assemble its parts:
import { Calendar } from '@base-ui/react/calendar';
<Calendar.Root>
<Calendar.DecrementMonth />
<Calendar.IncrementMonth />
<Calendar.DayGrid>
<Calendar.DayGridHeader>
<Calendar.DayGridHeaderRow>
<Calendar.DayGridHeaderCell />
</Calendar.DayGridHeaderRow>
</Calendar.DayGridHeader>
<Calendar.DayGridBody>
<Calendar.DayGridRow>
<Calendar.DayGridCell>
<Calendar.DayButton />
</Calendar.DayGridCell>
</Calendar.DayGridRow>
</Calendar.DayGridBody>
</Calendar.DayGrid>
</Calendar.Root>Examples
Unavailable dates
You can use the isDateUnavailable() prop to mark specific dates as unavailable. Unavailable dates are visually indicated and cannot be selected, but are focusable.
This example disables weekends, US holidays, and the first Monday of every month.
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
Validation
You can use the minDate and maxDate props to limit the range of selectable dates.
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
Lazy loading
You can render custom content inside <Calendar.DayButton> and use Calendar.useContext() to
react to month changes — for example, to lazily load per-day data.
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
Display week numbers
You can use useWeekList() and useDayList() hooks to build a calendar with additional DOM elements, like week numbers.
| # | S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|---|
| 10 | |||||||
| 11 | |||||||
| 12 | |||||||
| 13 | |||||||
| 14 |
Timezone support
You can use the timezone prop to display data in the calendar in your preferred timezone.
Timezone support is based on @date-fns/tz.
Calendar is displayed in America/New_York timezone.
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
Stored date: Thu Apr 17 2025 04:45:00 GMT+0200 (Central European Summer Time)
The calendar can display the date in a selected timezone.
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
Month and year select
Use Calendar.useContext() inside the calendar to read visibleDate and call setVisibleDate, enabling custom controls like the Select component for direct month and year navigation.
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
Animating month changes
You can use the <Calendar.Viewport> component to animate month transitions.
Wrapping the <Calendar.DayGridBody> in the <Calendar.Viewport> renders the previous month if a transition is in progress.
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
Animating with motion/react
You can use external animation libraries like Framer Motion to animate month transitions.
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
Localization
The calendar’s locale is controlled by the date library. It handles month and day names, as well as the start of the week.
You can use the <LocalizationProvider> to customize these settings.
API reference
Root
Groups all parts of the calendar.
Renders a <div> element.
defaultValueTemporalValue—
- Name
- Description
The uncontrolled value that should be initially selected. To render a controlled (Range)Calendar, use the
valueprop instead.- Type
Date | null | undefined
valueTemporalValue—
- Name
- Description
The controlled value that should be selected. To render an uncontrolled (Range)Calendar, use the
defaultValueprop instead.- Type
Date | null | undefined
onValueChangefunction—
- Name
- Description
Event handler called when the selected value changes. Provides the new value as an argument. Has
getValidationError()in theeventDetailsto retrieve the validation error associated to the new value.- Type
| (( value: TemporalValue, eventDetails: CalendarValueChangeEventDetails<ValidateDateReturnValue>, ) => void) | undefined
defaultVisibleDateDate—
- Description
The date used to decide which month should be initially displayed in the Day Grid. To render a controlled Calendar, use the
visibleDateprop instead.- Type
Date | undefined
visibleDateDate—
- Name
- Description
The date used to decide which month should be displayed in the Day Grid. To render an uncontrolled Calendar, use the
defaultVisibleDateprop instead.- Type
Date | undefined
onVisibleDateChangefunction—
- Description
Event handler called when the visible date changes. Provides the new date as an argument. Has the change reason in the
eventDetails.- Type
| (( visibleDate: Date, eventDetails: CalendarVisibleDateChangeEventDetails, ) => void) | undefined
isDateUnavailable((day: Date) => boolean)—
- Description
Mark specific dates as unavailable. Those dates will not be selectable but they will still be focusable with the keyboard.
- Type
((day: Date) => boolean) | undefined
maxDateDate—
- Name
- Description
Maximal selectable date.
- Type
Date | undefined
minDateDate—
- Name
- Description
Minimal selectable date.
- Type
Date | undefined
monthPageSizenumber1
- Name
- Description
The amount of months to move by when navigating. This is mostly useful when displaying multiple day grids.
- Type
number | undefined- Default
1
referenceDateDate'The closest valid date using the validation props.'
- Name
- Description
The date used to generate the new value when both
valueanddefaultValueare empty. It can be used to:- set a desired time on the selected date;
- set a desired default year or month;
- Type
Date | undefined- Default
'The closest valid date using the validation props.'
timezonestring'The timezone of the "value" or "defaultValue" prop if defined, "default" otherwise.'
- Name
- Description
Choose which timezone to use for the value. Example: "default", "system", "UTC", "America/New_York". If you pass values from other timezones to some props, they will be converted to this timezone before being used.
- Type
string | undefined- Default
'The timezone of the "value" or "defaultValue" prop if defined, "default" otherwise.'
disabledbooleanfalse
- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined- Default
false
readOnlybooleanfalse
- Name
- Description
Whether the user should be unable to select a date in the calendar.
- Type
boolean | undefined- Default
false
invalidbooleanfalse
- Name
- Description
Whether the calendar is forcefully marked as invalid. A calendar can be invalid when the selected date fails validation (i.e., is outside of the allowed
minDateandmaxDaterange).- Type
boolean | undefined- Default
false
childrenReactNode | ((parameters: CalendarContext) => ReactNode)—
- Name
- Description
The children of the component. If a function is provided, it will be called with the public context as its parameter.
- Type
| React.ReactNode | ((parameters: CalendarContext) => ReactNode)
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Calendar.Root.State) => string | undefined)
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: Calendar.Root.State, ) => CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Calendar.Root.State, ) => ReactElement)
data-disabled
data-readonly
data-invalid
data-empty
data-navigation-direction
| Attribute | Description | |
|---|---|---|
data-disabled | Present when the calendar is disabled. | |
data-readonly | Present when the calendar is readonly. | |
data-invalid | Present when the current value is invalid (fails validation). | |
data-empty | Present when the current value is empty. | |
data-navigation-direction | Indicates the direction of the navigation (based on the month navigating to). | |
DayGrid
Groups all the parts of the calendar's day grid.
Renders a <table> element.
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Calendar.DayGrid.State) => string | undefined)
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: Calendar.DayGrid.State, ) => CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Calendar.DayGrid.State, ) => ReactElement)
DayGridHeader
Groups all parts of the calendar's day grid header.
Renders a <thead> element.
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | (( state: Calendar.DayGridHeader.State, ) => string | undefined)
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: Calendar.DayGridHeader.State, ) => CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Calendar.DayGridHeader.State, ) => ReactElement)
DayGridHeaderCell
An individual day header cell in the calendar.
Renders a <th> element.
value*Date—
- Name
- Type
Date
formatter((date: Date) => string)(date) => adapter.format(date, 'EEE').charAt(0).toUpperCase()
- Name
- Description
The formatter function used to display the day of the week.
- Type
((date: Date) => string) | undefined- Default
(date) => adapter.format(date, 'EEE').charAt(0).toUpperCase()
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | (( state: Calendar.DayGridHeaderCell.State, ) => string | undefined)
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: Calendar.DayGridHeaderCell.State, ) => CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Calendar.DayGridHeaderCell.State, ) => ReactElement)
DayGridBody
Groups all parts of the calendar's day grid.
Renders a <tbody> element.
fixedWeekNumbernumber—
- Name
- Description
Will render the requested amount of weeks by adding weeks of the next month if needed. Set it to 6 to create a Gregorian calendar where all months have the same number of weeks.
- Type
number | undefined
offsetnumber0
- Name
- Description
The offset to apply to the rendered month compared to the current month. This is mostly useful when displaying multiple day grids.
- Type
number | undefined- Default
0
childrenReactNode | ((week: Date, index: number, weeks: Date[]) => ReactNode)—
- Name
- Description
The children of the component. If a function is provided, it will be called for each week to render as its parameter.
- Type
| React.ReactNode | (( week: Date, index: number, weeks: Date[], ) => ReactNode)
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | (( state: Calendar.DayGridBody.State, ) => string | undefined)
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: Calendar.DayGridBody.State, ) => CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Calendar.DayGridBody.State, ) => ReactElement)
DayGridRow
Groups all cells of a given calendar's day grid row.
Renders a <tr> element.
value*Date—
- Name
- Description
The date object representing the week.
- Type
Date
childrenReactNode | ((day: Date, index: number, days: Date[]) => ReactNode)—
- Name
- Description
The children of the component. If a function is provided, it will be called for each day of the week as its parameter.
- Type
| React.ReactNode | ((day: Date, index: number, days: Date[]) => ReactNode)
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Calendar.DayGridRow.State) => string | undefined)
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: Calendar.DayGridRow.State, ) => CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Calendar.DayGridRow.State, ) => ReactElement)
DayGridCell
An individual day cell in the calendar.
Renders a <td> element.
value*Date—
- Name
- Description
The value to select when this cell is clicked.
- Type
Date
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | (( state: Calendar.DayGridCell.State, ) => string | undefined)
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: Calendar.DayGridCell.State, ) => CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Calendar.DayGridCell.State, ) => ReactElement)
DayButton
An individual interactive day button in the calendar.
Renders a <button> element.
focusableWhenDisabledbooleanfalse
- Description
When
truethe item remains focusable when disabled.- Type
boolean | undefined- Default
false
nativeButtonbooleantrue
- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set tofalseif the rendered element is not a button (e.g.<div>).- Type
boolean | undefined- Default
true
formatstringadapter.formats.dayOfMonth
- Name
- Description
The format used to display the day.
- Type
string | undefined- Default
adapter.formats.dayOfMonth
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Calendar.DayButton.State) => string | undefined)
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: Calendar.DayButton.State, ) => CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Calendar.DayButton.State, ) => ReactElement)
data-selected
data-disabled
data-current
data-outside-month
data-unavailable
| Attribute | Description | |
|---|---|---|
data-selected | Present when the day is selected. | |
data-disabled | Present when the day is disabled. | |
data-current | Present when the day is the current date. | |
data-outside-month | Present when the day is outside the month rendered by the day grid wrapping it. | |
data-unavailable | Present when the day is unavailable. | |
DecrementMonth
Displays an element to navigate to the previous month in the calendar.
Renders a <button> element.
nativeButtonbooleantrue
- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set tofalseif the rendered element is not a button (e.g.<div>).- Type
boolean | undefined- Default
true
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | (( state: Calendar.DecrementMonth.State, ) => string | undefined)
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: Calendar.DecrementMonth.State, ) => CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Calendar.DecrementMonth.State, ) => ReactElement)
data-disabled
| Attribute | Description | |
|---|---|---|
data-disabled | Present when the button is disabled. | |
IncrementMonth
Displays an element to navigate to the next month in the calendar.
Renders a <button> element.
nativeButtonbooleantrue
- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set tofalseif the rendered element is not a button (e.g.<div>).- Type
boolean | undefined- Default
true
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | (( state: Calendar.IncrementMonth.State, ) => string | undefined)
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: Calendar.IncrementMonth.State, ) => CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Calendar.IncrementMonth.State, ) => ReactElement)
data-disabled
| Attribute | Description | |
|---|---|---|
data-disabled | Present when the button is disabled. | |
Viewport
A viewport for displaying calendar month transitions.
This component is only required if you want to animate certain part of a calendar when navigating between months.
The first rendered child element has to handle a ref.
Passes data-current to the currently visible content and data-previous to the previous content when animating between two.
Doesn't render its own HTML element.
children*React.JSX.Element—
- Name
- Description
The content to render inside the transition container.
- Type
React.JSX.Element
data-current
data-navigation-direction
data-previous
data-starting-style
data-ending-style
| Attribute | Description | |
|---|---|---|
data-current | Applied to the direct child of the viewport when no transitions are present or the new content when it's entering. | |
data-navigation-direction | Indicates the direction of the navigation (based on the month navigating to). | |
data-previous | Applied to the direct child of the viewport that contains the exiting content when transitions are present. | |
data-starting-style | Present when the day grid body is animating in. | |
data-ending-style | Present when the day grid body is animating out. | |