- Components
- Date and time
- Range Calendar
Range Calendar
A component that allows users to select a range of dates.
April 2025
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
Installation
Usage
Use RangeCalendar
to allow users to select a contiguous or non-contiguous range of dates.
Best practices
- An
aria-label
must be provided to theRangeCalendar
for accessibility. If it is labeled by a separate element, anaria-labelledby
prop must be provided using the id of the labeling element instead.
Uncontrolled
An initial, uncontrolled value can be provided to the RangeCalendar
using the defaultValue
prop.
February 2020
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
26 | 27 | 28 | 29 | 30 | 31 | 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
Controlled
The Range Calendar component can be controlled by passing the value
and onChange
props.
February 2020
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
26 | 27 | 28 | 29 | 30 | 31 | 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
Start date: 2020-02-03
End date: 2020-02-12
Validation
Min and max values
By default, Calendar allows selecting any date. The minValue and maxValue props can also be used to prevent the user from selecting dates outside a certain range.
This example only accepts dates after today.
April 2025
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
Unavailable dates
Calendar supports marking certain dates as unavailable. These dates cannot be selected by the user and are displayed with a crossed out appearance. The isDateUnavailable
prop accepts a callback that is called to evaluate whether each visible date is unavailable.
This example includes multiple unavailable date ranges, e.g. dates when a rental house is not available. The minValue
prop is also used to prevent selecting dates before today.
April 2025
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
Non-contiguous ranges
The allowsNonContiguousRanges
prop enables a range to be selected even if there are unavailable dates in the middle.
This example prevents selecting weekends, but allows selecting ranges that span multiple weeks.
April 2025
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
Error message
RangeCalendar
tries to avoid allowing the user to select invalid dates in the first place (see Min and max values and Unavailable dates). However, if according to application logic a selected date is invalid, Use isInvalid
and errorMessage
props.
This example validates that the selected date range is a maximum of 1 week in duration.
April 2025
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
Options
Visible months
By default, the RangeCalendar
displays a single month. The visibleMonths
prop allows displaying up to 3 months at a time.
April – May 2025
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Page behaviour
The pageBehavior
prop allows you to control how the range-calendar navigates between months.
April – May 2025
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Disabled
The isDisabled
boolean prop makes the RangeCalendar
disabled. cells cannot be focused or selected.
April 2025
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
Read only
The isReadOnly
boolean prop makes the RangeCalendar
's value immutable. Unlike isDisabled
, the RangeCalendar
remains focusable.
February 2020
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
26 | 27 | 28 | 29 | 30 | 31 | 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
Composition
If you need to customize things further, you can drop down to the composition level.
April 2025
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
API Reference
Prop | Type | Default | Description |
---|---|---|---|
visibleMonths | number | 1 | The number of months to display at once. Up to 3 months are supported. |
minValue | DateValue | - | The minimum allowed date that a user may select. |
maxValue | DateValue | - | The maximum allowed date that a user may select. |
isDateUnavailable | (date: DateValue) => boolean | - | Callback that is called for each date of the range calendar. If it returns true, then the date is unavailable. |
isDisabled | boolean | false | Whether the range calendar is disabled. |
isReadOnly | boolean | false | Whether the range calendar value is immutable. |
autoFocus | boolean | false | Whether to automatically focus the range calendar when it mounts. |
focusedValue | DateValue | - | Controls the currently focused date within the range calendar. |
defaultFocusedValue | DateValue | - | The date that is focused when the range calendar first mounts (uncountrolled). |
isInvalid | boolean | - | Whether the current selection is invalid according to application logic. |
pageBehavior | 'single' | 'visible' | 'visible' | Controls the behavior of paging. Pagination either works by advancing the visible page by visibleDuration (default) or one unit of visibleDuration. |
value | RangeValue<DateValue> | null | - | The current value (controlled). |
defaultValue | RangeValue<DateValue> | null | - | The default value (uncontrolled). |
children | ReactNode | (values: RangeCalendarRenderProps & {defaultChildren: ReactNode | undefined}) => ReactNode | - | The children of the component. A function may be provided to alter the children based on component state. |
className | string | - | The CSS className for the element. |
style | CSSProperties | (values: RangeCalendarRenderProps & {defaultStyle: CSSProperties}) => CSSProperties | - | The inline style for the element. A function may be provided to compute the style based on component state. |
Event | Type | Description |
---|---|---|
onFocusChange | (date: CalendarDate) => void | Handler that is called when the focused date changes. |
onChange | (value: RangeValue<MappedDateValue<DateValue>>) => void | Handler that is called when the value changes. |
Accessibility
Keyboard interactions
Key | Description |
---|---|
Tab | Moves focus to the next focusable item in the range calendar. |
Shift+Tab | Moves focus to the previous focusable item in the range calendar. |
ArrowRight | Moves focus to the next day. |
ArrowLeft | Moves focus to the previous day. |
ArrowDown | Moves focus to the same day of the week in the next week. |
ArrowUp | Moves focus to the same day of the week in the previous week. |
Space Enter | Selects the focused date. |