API: components
DateRangePickerInput
A DateRangePicker you can also type into, two ends of segments bound both ways to the picker's range, opt-in in an entry of its own.
A DateRangePicker whose range is also typed into
segments: the user types the start and the end into two groups of segments, as in a DateRangeField, or opens
the RangeCalendar with the Trigger, now the calendar button beside them. DateRangePickerInput.Root replaces the
picker's Root; the picker's Trigger, Portal, Positioner and Popup and the bound RangeCalendar are used
as they are (this entry exports DateRangePicker too). It is opt-in, in an entry of its own: a
picker without it imports no segment editing, and /date-range-picker is unchanged.
The APG has no date field: each segment is the APG spinbutton, as in a DateField, and the binding follows React Aria's DatePicker as the behaviour reference (the behaviour rule).
Behaviour
- Typing sets the value only when the entry is complete and valid (every segment set, inside
min/max, not unavailable, the end not before the start). An incomplete or invalid entry makes the valuenull, and its segments stay as typed (data-invalidwhile complete and invalid): the form never submits a date the calendar could not have chosen. - The calendar opens on the typed value and fills the segments when a date is chosen
(reason
item-press). With a timegranularity, the calendar chooses the date part: the typed time is kept, a time still empty takesplaceholderValue's (midnight). - The calendar never clears typed segments: opening and closing it, or an entry going back
to
null, leaves them as they are. One edit reports oneonValueChangeat most: no loop. - Field and form: inside a Field the label names the segments and a press
on it focuses the first one; the Trigger is named by the label and itself ("Departure Choose
date"). The form is the picker's: one hidden input with the ISO interval
start/end.
Anatomy
| part | element | data-primitives-part | role |
|---|---|---|---|
| Root | none | the picker's state and the segments' | |
| Segments | div | date-range-picker-segments | group of the segments of one end (range) |
| Segment | span | date-range-picker-segment | spinbutton, or a literal hidden from assistive technology |
| Trigger, Portal, Positioner, Popup | date-range-picker-* | the DateRangePicker's | |
| (hidden input) | input | date-range-picker-input | the picker's form value |
Usage
import { DateRangePicker, DateRangePickerInput } from "@fragiola/primitives-react/date-range-picker-input";
<Field.Root name="stay">
<Field.Label>Stay</Field.Label>
<DateRangePickerInput.Root value={value} onValueChange={setValue} min={today}>
<DateRangePickerInput.Segments range="start" aria-label="Check-in" />
<span aria-hidden="true">–</span>
<DateRangePickerInput.Segments range="end" aria-label="Check-out" />
<DateRangePicker.Trigger aria-label="Choose dates">📅</DateRangePicker.Trigger>
<DateRangePicker.Portal>
<DateRangePicker.Positioner>
<DateRangePicker.Popup aria-label="Choose dates">
<RangeCalendar.Root>{/* … */}</RangeCalendar.Root>
</DateRangePicker.Popup>
</DateRangePicker.Positioner>
</DateRangePicker.Portal>
</DateRangePickerInput.Root>
</Field.Root>;Props
Every part also takes what the primitive contract gives. Vue
binds v-model:value and v-model:open; Angular [(value)], [(open)],
(valueChangeDetails), (openChangeDetails). The other parts' props are the
DateRangePicker's.
Root
| prop | type | default | description |
|---|---|---|---|
value | DateRangeFieldValue | null | the range, controlled; set only from a complete, valid entry | |
defaultValue | DateRangeFieldValue | null | null | the initial range, uncontrolled |
onValueChange | (value, details: { reason, event }) => void | every change: input-change, input-clear, keyboard (typed), item-press (chosen), none (a reset) | |
open | boolean | the open state, controlled | |
defaultOpen | boolean | false | the initial open state, uncontrolled |
onOpenChange | (open: boolean, details: OpenChangeDetails) => void | every change, with its reason (trigger-press, item-press, escape-key, outside-press, focus-out); called before the change, details.cancel() stops it | |
onOpenChangeComplete | (open: boolean) => void | once an opening or a closing has finished its transitions (not on the first render, nor for an exit a reopening interrupted) | |
actionsRef (react) | { current: OverlayActions | null } | receives close() (reason imperative-action) and unmount() (ends an exit now); Vue exposes them on the Root's template ref, Angular as the root directive's methods | |
min | PlainDate | null | the calendar's and the segments' | |
max | PlainDate | null | the calendar's and the segments' | |
isDateUnavailable | (date: PlainDate) => boolean | the calendar's and the segments' | |
locale | string | the document's lang | the calendar's and the segments' |
calendar | CalendarSystem | the ISO calendar | a calendar system: the bound calendar and the segments show and edit its year, month (up to 13) and day, and an era where it has several; values stay ISO |
timeZone | TimeZone | a time zone (timeZone("America/New_York") from @fragiola/primitives/time-zone): the values are ZonedDateTimes in it, a time granularity shows its name, and the form submits 2026-11-01T01:30-05:00[America/New_York] | |
hideTimeZone | boolean | false | leaves the zone's name segment out |
disambiguation | "compatible" | "earlier" | "later" | "reject" | "compatible" | how a wall time the zone skips or repeats (a DST change) resolves, Temporal's; reject makes no value |
firstDayOfWeek | number | the locale's | passed to the bound calendar |
visibleMonths | number | 1 | passed to the bound calendar |
name | string | the hidden input's form name (a Field's wins); without one, no input is rendered | |
required | boolean | false | a native form's validation blocks a submission with no date |
disabled | boolean | false | the Trigger cannot open the popup; the hidden input submits nothing |
readOnly | boolean | false | the popup still opens; its calendar can be browsed, no date chosen |
granularity | "day" | "hour" | "minute" | "second" | "day" | a time granularity adds the time's segments; the calendar chooses the date |
placeholderValue | PlainDate | PlainDateTime | today at midnight | what an arrow on an empty segment starts from, and a chosen date's time while the time is empty |
hourCycle | 12 | 24 | the locale's | a time granularity's clock |
Segments
| prop | type | default | description |
|---|---|---|---|
range | "start" | "end" | required | the end whose segments it holds |
Name each end with aria-label; its children as DateRangeField's Input.
Segment
| prop | type | default | description |
|---|---|---|---|
segment | DateSegment | required | one of the Segments' segments |
State and part attributes
The segments as DateField's, named date-range-picker-*;
the Trigger, the Popup and the hidden input as the DateRangePicker's.
Keyboard
On a segment, DateField's, across both ends; in the calendar, the DateRangePicker's.
Exports
| entry | exports |
|---|---|
@fragiola/primitives-react/date-range-picker-input | ChangeDetails, ChangeReason, DateFieldSegmentProps, DateFieldSegmentState, DateFieldState, DateFieldValue, DatePickerInputRootSharedProps, DateRange, DateRangeFieldInputProps, DateRangeFieldValue, DateRangePicker, DateRangePickerInput, DateRangePickerInputRootProps, DateSegment, PlainDate, PlainDateTime, RangeEnd, SegmentGranularity, SegmentType |
@fragiola/primitives-vue/date-range-picker-input | ChangeDetails, ChangeReason, DateFieldInputSlots, DateFieldSegmentProps, DateFieldSegmentState, DateFieldState, DateFieldValue, DatePickerInputRootSharedProps, DateRange, DateRangeFieldInputProps, DateRangeFieldValue, DateRangePicker, DateRangePickerInput, DateRangePickerInputRootEmits, DateRangePickerInputRootProps, DateSegment, PlainDate, PlainDateTime, RangeEnd, SegmentGranularity, SegmentType |
@fragiola/primitives-angular/date-range-picker-input | * (every export of the DateRangePicker entry), DateFieldSegment, DateFieldSegmentState, DateFieldState, DateFieldValue, DateRangeFieldInput, DateRangeFieldValue, DateRangePickerInputRoot, DateSegment, PlainDateTime, RangeEnd, SegmentGranularity, SegmentType |