Calendar
Lab componentCalendar
Calendar
enables users to quickly navigate to and select a single date or range of dates.
When the selectionVariant
prop is set to "single", the Calendar
component allows users to select only a single date, providing a straightforward and focused date selection experience.
When the selectionVariant
prop is set to "range", the Calendar
component allows users to select a date range, including both a start date and an end date, enabling a comprehensive date selection experience.
When the selectionVariant
prop is set to "multiselect", the Calendar
component allows users to select multiple individual dates, providing flexibility for selecting non-consecutive dates.
When the selectionVariant
prop is set to "offset", the Calendar
component allows users to select a date range by choosing a single start date, with the end date automatically determined based on a predefined offset.
Unselectable dates are visually distinct from selectable dates. When a user attempts to select an unselectable date, the calendar displays a tooltip with additional information. To implement this, use the isDayUnselectable
prop to pass a function that determines whether a day is unselectable and provides the tooltip description.
Disabled dates are not selectable. To implement this, use the isDayUnselectable
prop to pass a function that determines whether a day is unselectable and provides the tooltip description.
Highlighted dates are marked by a triangle in the top right corner, indicating an event associated with that day. When a user hovers over a highlighted date, the calendar displays a tooltip with additional information. To implement this, use the isDayHighlighted
prop to pass a function that determines whether a day is highlighted and provides the tooltip description.
To customize the rendering of a day element, use the renderDayContents
prop with the Calendar
component. This prop accepts a function that is passed a DateValue
and returns the custom element for that day. This can be useful for scenarios where you need to display additional information or apply custom styling to specific dates.
By default, dates outside the visible month are out-of-range and visually distinct from the current month's dates. To hide these out-of-range dates, use the hideOutOfRangeDates
prop.
To hide the year dropdown, use the hideYearDropdown
prop with the CalendarNavigation
component. This can be useful in scenarios such as when the calendar is composed with other calendars or when the date selection does not require a year.
To constrain the selected date within a specific range, use the minDate
and/or maxDate
props. If minDate
is not provided, it defaults to the year 1900. If maxDate
is undefined, it defaults to the year 2100. This ensures that the selected date remains within the specified range.
A Calendar
component with a border provides a visually distinct area for selecting dates, enhancing the user interface by clearly delineating the calendar boundaries. This styling can improve usability and accessibility by making the calendar controls more noticeable and easier to interact with.
The Twin Calendars example demonstrates how to use the Calendar
component with the minDate
and maxDate
props to create an effective date range picker. By configuring two Calendar
components side by side, users can easily select a start date and an end date within a specified range.
When the locale
prop is provided, the Calendar
component uses it to define the calendar's locale, ensuring that date formats, month names, and other locale-specific elements are displayed according to the specified locale.
When the children
prop is used, the Calendar
component allows consumers to customize the calendar header, typically by composing it with the CalendarNavigation
component for forward/back month controls and month/year dropdowns, but it can also be used to add additional controls such as a 'Today' button.