Skip to content
v2.5.0
English
Русский
Documentation

Calendar

Calendar is an advanced interactive compound component for coordinated date selection across day, month, and year views.

Root API

Calendar is the root state container for the calendar system.

PropTypeDefault
maxstring—
Latest selectable date as a YYYY-MM-DD string. Months and years beyond this date become unavailable. Day, Month, and Year pickers use this to disable or clamp navigation.
minstring—
Earliest selectable date as a YYYY-MM-DD string. Months and years before this date become unavailable. All pickers respect this constraint when computing active ranges.
selectionS'single'
Selection mode. Determines the structure of value, all dates are YYYY-MM-DD strings: 'single' — a string, '' when nothing is selected; 'multiple' — an array of strings; 'range' — a [start, end] tuple with start not after end, '' marks an unset bound. Default: 'single'
viewCalendarView—
Controlled visible view: 'day' — the days of the visible month (CalendarDays); 'month' — the months of the visible year (CalendarMonths); 'year' — pages of years (CalendarYears)
valueCalendarValue<S>—
Controlled selection value, shaped by the selection mode. Malformed or non-existent dates are treated as unselected.
defaultValueCalendarValue<S>—
Uncontrolled initial selection value, shaped by the selection mode.
defaultViewCalendarView'day'
Initial view for uncontrolled usage. Default: 'day'
disabledboolean—
Disables the whole calendar: no date can be selected and navigation is off.
disabledDatesCalendarDatesDisabled—
Dates that cannot be selected, as YYYY-MM-DD strings: a single date; an array of dates; a predicate (date: string) => boolean
onChangeValue(value: CalendarValue<S>) => void—
Fires when the user changes the selection. The value is shaped by the selection mode.
onChangeView(view: CalendarView) => void—
Fires when the visible view changes.
monthstring—
Controlled visible month, given as a YYYY-MM-DD string of any day in that month.
defaultMonthstring—
Initial visible month for uncontrolled usage, given as a YYYY-MM-DD string of any day in that month. Default: the month of the selected date, otherwise the current month
onChangeMonth(month: string) => void—
Fires with the first day of the visible month as a YYYY-MM-DD string when the visible month changes (e.g., via scrolling or the month and year pickers). This event represents view navigation, not selection.
calendarCalendarSystemgregorianCalendar
Calendar system the calendar is shown in. Values stay YYYY-MM-DD days. Defaults to the Gregorian calendar.
localestring—
BCP 47 locale of month and day names and of the first day of the week, e.g. de-DE. Applies to all parts of the calendar and sets lang on the root. Defaults to the locale of the runtime, like Intl.
sizeCalendarBaseSize'xs'
Global size scale for the calendar. Affects nested controls such as navigation buttons, picker triggers, and week labels via CalendarBaseContext.
variantCalendarBaseVariant'secondary'
Visual variant for the calendar. Propagated through CalendarBaseContext and used by nested controls (buttons, labels, etc.) to keep styling consistent.
compactboolean—
Density flag for more compact layouts. When true, the root element receives data-compact="true", allowing styles to reduce paddings, gaps, and control heights for a denser calendar presentation. When false or undefined, the calendar uses the default spacing.

Also accepts all <div> attributes.

Child Parts API

The public child parts are grouped into four families:

  • header and navigation parts
  • view switching buttons
  • views
  • cell templates
PartNotes
CalendarHeader, CalendarContentLayout wrappers.
CalendarPrevButton, CalendarNextButtonPrevious / next month in the days, previous / next page of years in the years; hidden in the months view. Show a chevron unless children are given.
CalendarViewButtonGroupGroups the view buttons.
CalendarViewButtonToggles that view, aria-pressed while it is shown.
CalendarMonthLabel, CalendarYearLabelVisible month and year in the locale of the root.
CalendarDaysDay view; holds CalendarWeekdays and CalendarWeeks.
CalendarWeekdaysWeekday names in the locale of the root.
CalendarWeeksSwipeable day grid.
CalendarMonthsMonths of the visible year.
CalendarYearsSwipeable pages of years.
CalendarWeekdayWeekday template; without children it shows the weekday name.
CalendarDay, CalendarMonth, CalendarYearCell templates; without children they show the formatted label.

The views take only HTML attributes and display options. The month, selection, disabled dates, locale, calendar system, size and variant come from the Calendar root.

Children of CalendarWeekdays, CalendarWeeks, CalendarMonths, and CalendarYears are a template rendered once per weekday or cell. They are required, usually <CalendarWeekday />, <CalendarDay />, <CalendarMonth />, or <CalendarYear />.

The child parts should be treated as one coordinated system, not as isolated widgets.

CalendarHeader

Also accepts all <div> attributes.

CalendarPrevButton

PropTypeDefault
sizeIconButtonSize—
Size of the button container. Controls padding and overall clickable area.
asChildboolean—
When true, renders the button as a child component using Slot (e.g., from Radix UI). Enables polymorphic rendering — useful for making the button act as a link or custom tag.
variantButtonBaseVariant—
Defines the visual style of the button, affecting color schemes and emphasis.
appearanceButtonBaseAppearance—
Adjusts the button's structural appearance (background, border, etc.).
disabledboolean—
Disables the button when true. Prevents user interaction and applies a visually disabled state. Not applied with asChild: the child element owns its disabled state, for example, aria-disabled or a link without href.
classNamestring—
Optional custom CSS class for the button element. Useful for design system overrides or scoped styles.
childrenReactNode—
Content of the button — text, icon, or any React node.
refRef<HTMLButtonElement>—
Ref forwarded to the native <button> element. Allows direct DOM access for focus management or measuring.

Also accepts all <button> attributes.

CalendarNextButton

PropTypeDefault
sizeIconButtonSize—
Size of the button container. Controls padding and overall clickable area.
asChildboolean—
When true, renders the button as a child component using Slot (e.g., from Radix UI). Enables polymorphic rendering — useful for making the button act as a link or custom tag.
variantButtonBaseVariant—
Defines the visual style of the button, affecting color schemes and emphasis.
appearanceButtonBaseAppearance—
Adjusts the button's structural appearance (background, border, etc.).
disabledboolean—
Disables the button when true. Prevents user interaction and applies a visually disabled state. Not applied with asChild: the child element owns its disabled state, for example, aria-disabled or a link without href.
classNamestring—
Optional custom CSS class for the button element. Useful for design system overrides or scoped styles.
childrenReactNode—
Content of the button — text, icon, or any React node.
refRef<HTMLButtonElement>—
Ref forwarded to the native <button> element. Allows direct DOM access for focus management or measuring.

Also accepts all <button> attributes.

CalendarViewButtonGroup

Also accepts all <div> attributes.

CalendarViewButton

PropTypeDefault
viewrequiredExclude<CalendarView, 'day'>—
View the button opens: 'month' for CalendarMonths, 'year' for CalendarYears. Pressing it again goes back to the days.
asChildboolean—
When true, renders the button as a child component using Slot (e.g., from Radix UI). Enables polymorphic rendering — useful for making the button act as a link or custom tag.
sizeButtonSize—
Defines the size of the button. Affects padding, font size, and overall dimensions.
fullWidthboolean—
When true, the button expands to fill the width with its container.
variantButtonBaseVariant—
Defines the visual style of the button, affecting color schemes and emphasis.
appearanceButtonBaseAppearance—
Adjusts the button's structural appearance (background, border, etc.).
disabledboolean—
Disables the button when true. Prevents user interaction and applies a visually disabled state. Not applied with asChild: the child element owns its disabled state, for example, aria-disabled or a link without href.
classNamestring—
Optional custom CSS class for the button element. Useful for design system overrides or scoped styles.
childrenReactNode—
Content of the button — text, icon, or any React node.
refRef<HTMLButtonElement>—
Ref forwarded to the native <button> element. Allows direct DOM access for focus management or measuring.

Also accepts all <button> attributes.

CalendarMonthLabel

PropTypeDefault
formatIntl.DateTimeFormatOptions['month']'long'
Month display format (from Intl.DateTimeFormatOptions). Defines how the month name should appear. Possible values: "long" → January (default); "short" → Jan; "narrow" → J

CalendarYearLabel

PropTypeDefault
formatIntl.DateTimeFormatOptions['year']'numeric'
Format of the displayed year (from Intl.DateTimeFormatOptions). Possible values: "numeric" → 2026; "2-digit" → 26. Default is typically "numeric".

CalendarContent

Also accepts all <div> attributes.

CalendarDays

Also accepts all <div> attributes.

CalendarWeekdays

PropTypeDefault
formatIntl.DateTimeFormatOptions['weekday']'short'
Format of the weekday names (Intl.DateTimeFormat weekday).
childrenrequiredReactNode—
Template rendered once per weekday, usually <CalendarWeekday />. Read the weekday with useCalendarWeekdayContext().

Also accepts all <div> attributes.

CalendarWeekday

PropTypeDefault
sizeTextSize—
Visual size of the text, typically mapped to the design system’s type scale.
asChildboolean—
If true, renders the text as a child component using Slot. Useful for compatibility with native elements or other components.
fontWeight400 | 500 | 600 | 700 | 900—
Font weight applied to the text. Common values: 400: Regular; 500: Medium; 600: Semi-bold; 700: Bold; 900: Extra bold
refRef<HTMLSpanElement>—
Ref to the underlying <span> or slotted element. Useful for measuring, focusing, or DOM manipulation.

Also accepts all <span> attributes.

CalendarWeeks

PropTypeDefault
childrenrequiredReactNode—
Template of a day cell, rendered once for every day of the visible months. Read the day with useCalendarDayContext(); usually <CalendarDay />.
formatIntl.DateTimeFormatOptions['day']"numeric"
Format of the day numbers (Intl.DateTimeFormat day).
includeOverflowDaysbooleanfalse
Whether days of the previous and next months fill the empty cells.
startnumber-2
Starting index used to generate the initial sequence of pages. Acts as the logical origin for the sliding index window.
sizenumber5
Number of index segments rendered at once. Defines the size of the virtual “window” that the scroller slides over when navigating left or right.
startDir-1 | 11
Direction in which the initial index sequence expands. 1 — indexes increase to the right (0, 1, 2…); -1 — indexes decrease to the right (0, -1, -2…). Controls the growth pattern of the initial index array.
shiftnumber2
Number of pages appended when a scroll reaches the end of the window, so a fast swipe keeps going. Once the scroll settles, the window is re-centered on the snapped page.
indexnumber—
Controls the currently active logical index. When provided, the scroller keeps the given index in view, scrolling to it if possible or rebuilding the window if needed.
preserveScrollbooleantrue
Preserve the currently snapped item after content changes (e.g., when pages are prepended/appended). If true, the scroller will restore the same snapped index using an immediate scrollIntoView.
onOffset(value: number) => void—
Fires when the window grows at an edge. -1 — the scroll settled on the first page (left/top edge); +1 — the scroll reached the end (right/bottom edge). Useful for infinite loading: append/prepend pages based on the direction.
refRef<HTMLDivElement>—
Ref to the scroller’s element.
defaultIndexnumber—
Initial index of the item to snap to on mount.
onScrollSnapChange(element: HTMLElement, index: number) => void—
Fired when a scroll snap operation has fully completed and the scroller has settled on a new snap index. This callback is invoked after all scrolling and snapping animations have finished and the active snap position is considered stable.
onScrollSnapChanging(element: HTMLElement, index: number) => void—
Fired while a scroll snap operation is in progress and the active snap index is still changing. This callback may be invoked multiple times during a single scroll or swipe interaction as the scroller approaches its final snap position. Useful for optimistic UI updates, previews, or synchronizing transient state during scrolling.

Also accepts all <div> attributes.

CalendarDay

PropTypeDefault
sizeDataGridPickerSize—
Controls the item’s visual size. Useful for adapting the picker to compact or large layouts.
rangeDataGridPickerItemRangePosition—
Optional visual indicator of the cell’s position within a range. One of: "start" | "between" | "end". If not provided, the component automatically derives it based on selection context.
variantDataGridPickerVariant—
Visual appearance preset for the picker.
disabledboolean—
Disables click and keyboard selection. Overrides value from root DataGrid
refRef<HTMLDivElement>—
External ref to the cell root element. Will be merged with the internal itemRef([row, col], key) registration when the cell is not excluded.
asChildbooleanfalse
When true, renders children via Slot and forwards props/refs to the child element instead of using a native <div>.
excludedboolean—
Exclude cells from focus traversal. Overrides value from root DataGrid

Also accepts all <div> attributes.

CalendarMonths

PropTypeDefault
childrenrequiredReactNode—
Template of a month cell, rendered once for every month of the visible year. Read the month with useCalendarMonthContext(); usually <CalendarMonth />.
colsnumber3
Number of columns of the month grid.
formatIntl.DateTimeFormatOptions['month']"long"
Format of the month names (Intl.DateTimeFormat month).

Also accepts all <div> attributes.

CalendarMonth

PropTypeDefault
sizeDataGridPickerSize—
Controls the item’s visual size. Useful for adapting the picker to compact or large layouts.
rangeDataGridPickerItemRangePosition—
Optional visual indicator of the cell’s position within a range. One of: "start" | "between" | "end". If not provided, the component automatically derives it based on selection context.
variantDataGridPickerVariant—
Visual appearance preset for the picker.
disabledboolean—
Disables click and keyboard selection. Overrides value from root DataGrid
refRef<HTMLDivElement>—
External ref to the cell root element. Will be merged with the internal itemRef([row, col], key) registration when the cell is not excluded.
asChildbooleanfalse
When true, renders children via Slot and forwards props/refs to the child element instead of using a native <div>.
excludedboolean—
Exclude cells from focus traversal. Overrides value from root DataGrid

Also accepts all <div> attributes.

CalendarYears

PropTypeDefault
childrenrequiredReactNode—
Template of a year cell, rendered once for every year of the visible pages. Read the year with useCalendarYearContext(); usually <CalendarYear />.
formatIntl.DateTimeFormatOptions['year']"numeric"
Format of the years (Intl.DateTimeFormat year).

Also accepts all <div> attributes.

CalendarYear

PropTypeDefault
sizeDataGridPickerSize—
Controls the item’s visual size. Useful for adapting the picker to compact or large layouts.
rangeDataGridPickerItemRangePosition—
Optional visual indicator of the cell’s position within a range. One of: "start" | "between" | "end". If not provided, the component automatically derives it based on selection context.
variantDataGridPickerVariant—
Visual appearance preset for the picker.
disabledboolean—
Disables click and keyboard selection. Overrides value from root DataGrid
refRef<HTMLDivElement>—
External ref to the cell root element. Will be merged with the internal itemRef([row, col], key) registration when the cell is not excluded.
asChildbooleanfalse
When true, renders children via Slot and forwards props/refs to the child element instead of using a native <div>.
excludedboolean—
Exclude cells from focus traversal. Overrides value from root DataGrid

Also accepts all <div> attributes.

Hooks

useCalendarContext

Advanced hook for custom parts. Exposes the root state, including view, month, locale, calendar, toggleView(view), closeView(), prev(), and next().

useCalendarWeekdayContext

Weekday of the surrounding CalendarWeekdays template:

FieldTypeNotes
colnumberColumn index within the row.
weekdaynumberDay of the week as in Date#getDay(): 0 is Sunday, 6 is Saturday.
labelstringWeekday name in the locale of the root.

useCalendarDayContext

Day of the surrounding CalendarWeeks template:

FieldTypeNotes
colnumberColumn index within the week.
datestring | undefinedISO YYYY-MM-DD day; undefined for an empty overflow cell.
fieldsCalendarDateFields | undefinedDay in the calendar system: { era?, year, month, day }.
labelstringFormatted day number in the locale and calendar system.
inMonthbooleanWhether the day belongs to the rendered month.

useCalendarMonthContext / useCalendarYearContext

Month or year of the surrounding CalendarMonths / CalendarYears template: col, date (first day of the month or year, ISO), fields, and label.

Take the day, month, or year number from label or fields, never from the ISO date string: in non-Gregorian calendars they differ.

Types

TypeDefinitionNotes
CalendarPropsRoot prop typeMain integration surface.
CalendarViewview union'day', 'month', or 'year'.
CalendarSelectionselection unionsingle, multiple, or range.
CalendarValueselection value by modeYYYY-MM-DD string, [start, end] tuple (start never after end), or array of strings.
CalendarDatesDisableddisabled-date contractYYYY-MM-DD string, array of strings, or a (date: string) => boolean predicate.

State Model

  • Visible date and selection state live in the root.
  • Selection mode changes the expected value shape.
  • Views coordinate around the same root state.
  • view determines which of days, months, or years is visible and drives the previous and next buttons.
  • locale and calendar are root props read by every part; the default is the runtime locale and the Gregorian calendar.

Integration Notes

  • Pass ISO YYYY-MM-DD strings to the component layer and keep them as the stored value; convert to other formats in the application layer.
  • calendar changes how days are grouped and labeled, not the value. See Dates And Calendar Systems.
  • Retest custom cell templates and overflow cells carefully.
  • Use the lower-level DayPicker, MonthPicker, and YearPicker only when the full Calendar composition is not needed.
  • Reach for DayPicker, MonthPicker, YearPicker, or CalendarBase only when building custom calendar-family behavior, not as a first choice for normal date picking flows.