Range Calendar

size
mode
disabled
readOnly
minValue
maxValue
focusedValue
import {RangeCalendar} from '@gravity-ui/date-components';

RangeCalendar is a powerful, flexible, and user-friendly UI component designed for selecting a range of dates. Built with React, it combines the functionality of a calendar and a date range picker, making it an ideal choice for applications that require users to input a start and end date. It can be controlled if you set value property. Or it can be uncontrolled if you don't set any value, but in this case you can manage the initial state with optional property defaultValue. Component is uncontrolled by default.

Useful addition

To set dates in the right format you may need to include additional helpers from Date Utils library

import {dateTimeParse, dateTime} from '@gravity-ui/date-utils';

[!NOTE] Row with "Selected range: ..." is not a part of the component. It was added to examples only for clarity.

Size

To control the size of the RangeCalendar use the size property. Default size is m.

Selected range:
 
Selected range:
 
Selected range:
 
<RangeCalendar size="m" />
<RangeCalendar size="l" />
<RangeCalendar size="xl" />

Value

Min and max value

The minValue property allows you to specify the earliest date and time that can be entered by the user. Conversely, the maxValue property specifies the latest date and time that can be entered. All other values will be disabled for user.

Selected range:
 
<RangeCalendar minValue={dateTimeParse('01.01.2024')} maxValue={dateTimeParse('01.01.2025')} />

Mode

Defines the time interval that RangeCalendar should display. With mode you can choose it in controlled way. For uncontrolled way you don't need to specify any value. Also you can set the initial mode in uncontrolled way with defaultMode prop.

days - default mode for RangeCalendar. It shows days in month.

months - shows months in year

quarters - shows quarters by years (not available as value in defaultMode)

years - shows several years for select

You can limit enabled modes by using prop modes.

Selected range:
 
<RangeCalendar defaultMode="months"/>

States

Disabled

The state of the RangeCalendar where you don't want the user to be able to interact with the component.

Selected range:
07/02/2025 - 07/06/2025
<RangeCalendar
  disabled={true}
  defaultValue={{start: dateTime().add({days: 2}), end: dateTime().subtract({days: 2})}}
/>

Readonly

readOnly is a boolean attribute that, when set to true, makes the RangeCalendar component immutable to the user. This means that while the input will display its current value, users will not be able to change it.

Selected range:
07/02/2025 - 07/06/2025
<RangeCalendar
  readOnly={true}
  defaultValue={{start: dateTime().add({days: 2}), end: dateTime().subtract({days: 2})}}
/>

Focused value

Allows to select the date that RangeCalendar view is focused on. If you need it to be controlled you shoud use focusedValue prop. You can set the initial focused value for uncontrolled component with optional prop defaultFocusedValue.

Selected range:
07/02/2025 - 07/06/2025
<RangeCalendar
  defaultFocusedValue={dateTimeParse('01.01.2020')} defaultValue={{start: dateTime().add({days: 2}), end: dateTime().subtract({days: 2})}}
/>

Time zone

timeZone is the property to set the time zone of the value in the input. Learn more about time zones

Properties

NameDescriptionTypeDefault
aria-describedbyThe control's aria-describedby attributestring
aria-detailsThe control's aria-details attributestring
aria-labelThe control's aria-label attributestring
aria-labelledbyThe control's aria-labelledby attributestring
autoFocusThe control's autofocus attributeboolean
classNameThe control's wrapper class namestring
defaultFocusedValueThe date that is focused when the calendar first mounts (uncontrolled)DateTime
defaultModeInitial mode to show in calendardays months quarters years
defaultValueSets the initial value for uncontrolled component.RangeValue<DateTime>
disabledIndicates that the user cannot interact with the controlbooleanfalse
focusedValueSet the default view of uncontrolled component which includes this valueDateTime null
idThe control's id attributestring
isDateUnavailableCallback that is called for each date of the calendar. If it returns true, then the date is unavailable.((date: DateTime) => boolean)
isWeekendCallback that is called for each date of the calendar. If it returns true, then the date is weekend.((date: DateTime) => boolean)
maxValueThe maximum allowed date that a user may select.DateTime
minValueThe minimum allowed date that a user may select.DateTime
modeDefines the time interval that RangeCalendar should display in colttrolled way.days months quarters years
modesModes available to userPartial<Record<RangeCalendarLayout, boolean>>{days: true, months: true, quarters: false, years: true }
onBlurFires when the control lost focus. Provides focus event as a callback's argument((e: FocusEvent<Element, Element>) => void)
onFocusFires when the control gets focus. Provides focus event as a callback's argument((e: FocusEvent<Element, Element>) => void)
onFocusUpdateFires when the control's focused date changes.((date: DateTime) => void)
onUpdateFires when the value is changed.((value: DateTime) => void
onUpdateModeFires when the mode is changed.((value: 'days' | 'months' | 'quarters' | 'years' ) => void
readOnlyWhether the calendar value is immutable.booleanfalse
sizeThe size of the control"m" "l" "xl""m"
styleSets inline style for the element.CSSProperties
timeZoneSets the time zone. Learn more about time zonesstring
valueThe value of the controlRangeValue<DateTime> null