Skip to content

Calendar

Import

import {
UNSTABLE_Calendar,
UNSTABLE_RangeCalendar,
UNSTABLE_CalendarGrid,
UNSTABLE_CalendarCell,
} from "@cfa/react-core";
import { CalendarDate, today, getLocalTimeZone } from "@internationalized/date";

Basic Usage

The Calendar component allows users to select a single date.

Date Highlighting

Highlight specific dates in the calendar using the isDateHighlighted prop. This example highlights the 1st and 15th of each month.

Date Restrictions

Set minimum and maximum dates to restrict selection, or disable specific dates.

Multiple Months

Display multiple months at once using the visibleDuration prop.

RangeCalendar

For selecting date ranges, use the RangeCalendar component.

Import

import {
UNSTABLE_Calendar as Calendar,
UNSTABLE_RangeCalendar as RangeCalendar,
UNSTABLE_CalendarGrid as CalendarGrid,
UNSTABLE_CalendarCell as CalendarCell,
} from "@cfa/react-core";
import { CalendarDate } from "@internationalized/date";

Basic Range Selection

Subcomponents

import {
UNSTABLE_Calendar as Calendar,
UNSTABLE_CalendarGrid as CalendarGrid,
UNSTABLE_CalendarCell as CalendarCell,
} from "@cfa/react-core";
import { CalendarDate } from "@internationalized/date";

CalendarGrid & CalendarCell

The CalendarGrid component renders the calendar grid structure. It’s typically used internally but can be used for custom calendar layouts.

The CalendarCell component renders individual date cells within the calendar grid.

Props

Visit the

Documentation Site

for the full list of props.

NameTypeDefaultDescription
errorMessagestring--
isDateHighlighted(date: T) => boolean--
aria-describedbystring-Identifies the element (or elements) that describes the object.
aria-detailsstring-Identifies the element (or elements) that provide a detailed, extended description for the object.
aria-labelstring-Defines a string value that labels the current element.
aria-labelledbystring-Identifies the element (or elements) that labels the current element.
autoFocusbooleanfalseWhether to automatically focus the calendar when it mounts.
childrenChildrenOrFunction<CalendarRenderProps>-The children of the component. A function may be provided to alter the children based on component state.
classNameClassNameOrFunction<CalendarRenderProps>'react-aria-Calendar'The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.
createCalendar(identifier: CalendarIdentifier) => Calendar-A function to create a new [Calendar](https://react-spectrum.adobe.com/internationalized/date/Calendar.html) object for a given calendar identifier. If not provided, the `createCalendar` function from `@internationalized/date` will be used.
defaultFocusedValueDateValue-The date that is focused when the calendar first mounts (uncontrolled).
defaultValueDateValue-The default value (uncontrolled).
dirstring--
firstDayOfWeek"sun" | "mon" | "tue" | "wed" | "thu" | "fri" | "sat"-The day that starts the week.
focusedValueDateValue-Controls the currently focused date within the calendar.
hiddenboolean--
idstring-The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).
inertboolean--
isDateUnavailable(date: DateValue) => boolean-Callback that is called for each date of the calendar. If it returns true, then the date is unavailable.
isDisabledbooleanfalseWhether the calendar is disabled.
isInvalidboolean-Whether the current selection is invalid according to application logic.
isReadOnlybooleanfalseWhether the calendar value is immutable.
langstring--
maxValueDateValue-The maximum allowed date that a user may select.
minValueDateValue-The minimum allowed date that a user may select.
onAnimationEndAnimationEventHandler<HTMLDivElement>--
onAnimationEndCaptureAnimationEventHandler<HTMLDivElement>--
onAnimationIterationAnimationEventHandler<HTMLDivElement>--
onAnimationIterationCaptureAnimationEventHandler<HTMLDivElement>--
onAnimationStartAnimationEventHandler<HTMLDivElement>--
onAnimationStartCaptureAnimationEventHandler<HTMLDivElement>--
onAuxClickMouseEventHandler<HTMLDivElement>--
onAuxClickCaptureMouseEventHandler<HTMLDivElement>--
onChange(value: MappedDateValue<T>) => void-Handler that is called when the value changes.
onClickMouseEventHandler<HTMLDivElement>--
onClickCaptureMouseEventHandler<HTMLDivElement>--
onContextMenuMouseEventHandler<HTMLDivElement>--
onContextMenuCaptureMouseEventHandler<HTMLDivElement>--
onDoubleClickMouseEventHandler<HTMLDivElement>--
onDoubleClickCaptureMouseEventHandler<HTMLDivElement>--
onFocusChange(date: CalendarDate) => void-Handler that is called when the focused date changes.
onGotPointerCapturePointerEventHandler<HTMLDivElement>--
onGotPointerCaptureCapturePointerEventHandler<HTMLDivElement>--
onLostPointerCapturePointerEventHandler<HTMLDivElement>--
onLostPointerCaptureCapturePointerEventHandler<HTMLDivElement>--
onMouseDownMouseEventHandler<HTMLDivElement>--
onMouseDownCaptureMouseEventHandler<HTMLDivElement>--
onMouseEnterMouseEventHandler<HTMLDivElement>--
onMouseLeaveMouseEventHandler<HTMLDivElement>--
onMouseMoveMouseEventHandler<HTMLDivElement>--
onMouseMoveCaptureMouseEventHandler<HTMLDivElement>--
onMouseOutMouseEventHandler<HTMLDivElement>--
onMouseOutCaptureMouseEventHandler<HTMLDivElement>--
onMouseOverMouseEventHandler<HTMLDivElement>--
onMouseOverCaptureMouseEventHandler<HTMLDivElement>--
onMouseUpMouseEventHandler<HTMLDivElement>--
onMouseUpCaptureMouseEventHandler<HTMLDivElement>--
onPointerCancelPointerEventHandler<HTMLDivElement>--
onPointerCancelCapturePointerEventHandler<HTMLDivElement>--
onPointerDownPointerEventHandler<HTMLDivElement>--
onPointerDownCapturePointerEventHandler<HTMLDivElement>--
onPointerEnterPointerEventHandler<HTMLDivElement>--
onPointerLeavePointerEventHandler<HTMLDivElement>--
onPointerMovePointerEventHandler<HTMLDivElement>--
onPointerMoveCapturePointerEventHandler<HTMLDivElement>--
onPointerOutPointerEventHandler<HTMLDivElement>--
onPointerOutCapturePointerEventHandler<HTMLDivElement>--
onPointerOverPointerEventHandler<HTMLDivElement>--
onPointerOverCapturePointerEventHandler<HTMLDivElement>--
onPointerUpPointerEventHandler<HTMLDivElement>--
onPointerUpCapturePointerEventHandler<HTMLDivElement>--
onScrollUIEventHandler<HTMLDivElement>--
onScrollCaptureUIEventHandler<HTMLDivElement>--
onTouchCancelTouchEventHandler<HTMLDivElement>--
onTouchCancelCaptureTouchEventHandler<HTMLDivElement>--
onTouchEndTouchEventHandler<HTMLDivElement>--
onTouchEndCaptureTouchEventHandler<HTMLDivElement>--
onTouchMoveTouchEventHandler<HTMLDivElement>--
onTouchMoveCaptureTouchEventHandler<HTMLDivElement>--
onTouchStartTouchEventHandler<HTMLDivElement>--
onTouchStartCaptureTouchEventHandler<HTMLDivElement>--
onTransitionCancelTransitionEventHandler<HTMLDivElement>--
onTransitionCancelCaptureTransitionEventHandler<HTMLDivElement>--
onTransitionEndTransitionEventHandler<HTMLDivElement>--
onTransitionEndCaptureTransitionEventHandler<HTMLDivElement>--
onTransitionRunTransitionEventHandler<HTMLDivElement>--
onTransitionRunCaptureTransitionEventHandler<HTMLDivElement>--
onTransitionStartTransitionEventHandler<HTMLDivElement>--
onTransitionStartCaptureTransitionEventHandler<HTMLDivElement>--
onWheelWheelEventHandler<HTMLDivElement>--
onWheelCaptureWheelEventHandler<HTMLDivElement>--
pageBehaviorPageBehaviorvisibleControls the behavior of paging. Pagination either works by advancing the visible page by visibleDuration (default) or one unit of visibleDuration.
renderDOMRenderFunction<"div", CalendarRenderProps>-Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements: * You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`). * Only a single root DOM element can be rendered (no fragments). * You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
selectionAlignment"start" | "center" | "end"'center'Determines the alignment of the visible months on initial render based on the current selection or current date if there is no selection.
slotstring-A slot name for the component. Slots allow the component to receive props from a parent component. An explicit `null` value indicates that the local props completely override all props received from a parent.
styleStyleOrFunction<CalendarRenderProps>-The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. A function may be provided to compute the style based on component state.
translate"yes" | "no"--
valueDateValue-The current value (controlled).
visibleDurationDateDuration{months: 1}The amount of days that will be displayed at once. This affects how pagination works.