BetaForms

DateRangePicker

A field that opens a month, and takes two days from it.

Overview

A field that opens a month, and takes two days from it.

First example

<DateRangePicker value={stay} onValueChange={setStay}>
<DateRangePicker.Trigger>
<DateRangePicker.Value placeholder="Choisir un séjour" />
<DateRangePicker.Indicator />
</DateRangePicker.Trigger>
<DateRangePicker.Sheet previousLabel="Mois précédent" nextLabel="Mois suivant" />
</DateRangePicker>

Anatomy

<DateRangePicker>
  <DateRangePicker.Calendar />
  <DateRangePicker.Sheet />
  <DateRangePicker.Trigger />
  <DateRangePicker.Value />
</DateRangePicker>

Usage

<DateRangePicker value={stay} onValueChange={setStay}>
  <DateRangePicker.Trigger>
    <DateRangePicker.Value placeholder="Choisir un séjour" />
    <DateRangePicker.Indicator />
  </DateRangePicker.Trigger>
  <DateRangePicker.Sheet previousLabel="Mois précédent" nextLabel="Mois suivant" />
</DateRangePicker>

Root props

DateRangePickerProps

The node's inherited React Native props apply too, and so do its style props padding, margin, width and the rest.

PropTypeRequiredDescription
variantDateRangePickerVariant | undefinedNoDresses the **field**. `calendarVariant` dresses the month.
sizeDateRangePickerSize | undefinedNo
radiusRadiusKey | undefinedNo
colorstring | undefinedNo
calendarVariantCalendarVariant | undefinedNoThe month's own level. A `ghost` field over a `primary` month is the ordinary case.
valueDateRange | undefinedNoThe period chosen. Controlled — leave it out and the picker holds its own.
defaultValueDateRange | undefinedNo
onValueChange((value: DateRange) => void) | undefinedNo
isOpenboolean | undefinedNo
defaultOpenboolean | undefinedNo
onOpenChange((isOpen: boolean) => void) | undefinedNo
minValueDate | undefinedNo
maxValueDate | undefinedNo
firstDayOfWeekWeekDay | undefinedNo
localestring | undefinedNo
formatOptionsDateTimeFormatOptions | undefinedNoHow each end reads in the field.
separatorstring | undefinedNoWhat is written between the two ends in the field.
closeOnSelectboolean | undefinedNoWhether closing the **second** end closes the sheet. The first never does: a period is two decisions, and a sheet that shut after the first would make the second one a second opening.
isDisabledboolean | undefinedNo
isInvalidboolean | undefinedNo
childrenReactNodeNo

Slots

DateRangePickerCalendarProps

The node's inherited React Native props apply too, and so do its style props padding, margin, width and the rest.

PropTypeRequiredDescription
previousLabelstring | undefinedNo
nextLabelstring | undefinedNo

DateRangePickerSheetProps

The node's inherited React Native props apply too, and so do its style props padding, margin, width and the rest.

PropTypeRequiredDescription
previousLabelstring | undefinedNoThe month's two arrows, as on the `Calendar` itself.
nextLabelstring | undefinedNo

DateRangePickerTriggerProps

The node's inherited React Native props apply too, and so do its style props padding, margin, width and the rest.

PropTypeRequiredDescription
asChildboolean | undefinedNoMerge into the single child instead of rendering a pressable (R12) — **keeping the feedback**. Swapping this component out for a bare `Slot` would silently drop the touch feedback of every `asChild` control.
childrenReactNodeNo
styleStyleProp<ViewStyle> | ((state: PressableStateCallbackType) => StyleProp<ViewStyle>)NoR9 — `Pressable`'s function form as much as an object or an array.

DateRangePickerValueProps

The node's inherited React Native props apply too, and so do its style props padding, margin, width and the rest.

PropTypeRequiredDescription
childrenReactNodeNo
placeholderstring | undefinedNoWhat the field says with no period chosen.

Variants, sizes and colour

variant dresses the field, calendarVariant dresses the month

A ghost field over a primary month is the ordinary case — the trigger is quiet on the form and the chosen period is not.

minValue, maxValue, firstDayOfWeek and locale pass straight through. formatOptions is Intl.DateTimeFormatOptions and reads each end with it.

The root renders no node: ref, style and the a11y props live on DateRangePicker.Trigger.

Accessibility

The source defines no extra rule. Keep the React Native labels, roles, states and focus order your case needs, then check the result with VoiceOver and TalkBack.

Migration from legacy

This component declares no rule of its own. The migration guide covers variants, colours and slots.

Implementation notes

It owns almost nothing

The trigger is a Select's trigger and the month is a RangeCalendar, which is itself a Calendar. What this adds is the wiring: two ends read into the field through Intl, and a sheet that closes on the second one.

Every rule the RangeCalendar has — the third press, the backwards range, the one-day range — is this component's too, because it is that component.

A sheet rather than an anchored panel, for the TimePicker's reason: a month is three hundred points wide, which beside a field on a phone is the screen.

The first choice never closes the sheet

A period is two decisions, and a sheet that shut after the first would make the second one a second opening. closeOnSelect governs the second only.

A start with no end reads as itself

Not as "start – ". A dash with nothing after it says the field is broken, where a lone date says it is half answered — which is exactly what it is between the two presses.

The separator is an en dash with a space either side, not a hyphen: a hyphen is already the date separator in half the locales this field serves.

See also

  • DateRangeField — a period typed rather than chosen.
  • RangeCalendar — the month on its own.
  • DatePicker — one day rather than two.