Fragiola

API: components

DateRangeField

A start and an end date typed in segments as one control, an end before the start invalid, two form values and Field support, in each framework.

A start date and an end date typed in parts, as two DateField inputs in one control: a stay's check-in and check-out, a report's period. With a time granularity both ends are a date and a time. Each end is a group of segments you name ("Check-in", "Check-out"); each segment is the APG spinbutton, as in a DateField, with React Aria's DateRangePicker as the behaviour reference where the APG says nothing (the behaviour rule). TimeRangeField is the same anatomy over two times.

Stay dates
Gallery

Behaviour

  • Value: a DateRange ({ start, end } of PlainDates, or of PlainDateTimes with a time granularity), set only once every segment of both ends is; null until then.
  • One sequence: typing moves on from the start's last segment to the end's first, Backspace on an empty segment moves back across the ends, and ArrowLeft and ArrowRight cross them; moving between the ends is no blur of the Field.
  • An end before the start is still the value, and invalid (data-invalid, aria-invalid on every segment), as an end before min, after max or unavailable (isDateUnavailable).
  • Forms: two hidden native inputs, startName and endName, submit each ISO date. Their bounds cross: the start's max is the end, the end's min the start, so a reversed range is the browser's own rangeOverflow / rangeUnderflow (a native form refuses it, a Field shows its error); required refuses an empty range; a reset returns both ends to defaultValue.
  • Calendar systems and time zones: calendar, timeZone, hideTimeZone and disambiguation are a DateField's, for both ends. A zoned range's inputs are type="text" and submit the zoned ISO texts (2026-11-01T01:30-04:00[America/New_York]), with no native crossed bounds: a reversed range is still data-invalid.
  • No text: name each Input (aria-label); inside a Field, a segment is named by the label, its end and itself ("Stay Check-in month").

Anatomy

partelementdata-primitives-partrole
Rootdivdate-range-field-rootholds the value; renders the hidden inputs after it
Inputdivdate-range-field-inputgroup of one end's segments (range)
Segmentspandate-range-field-segmentspinbutton, or a literal hidden from assistive technology
(hidden inputs)input type="date" ×2date-range-field-hidden-inputwhat the form submits, data-range="start" / "end"

Usage

import { DateRangeField } from "@fragiola/primitives-react/date-range-field";

<DateRangeField.Root value={stay} onValueChange={setStay} min={today} startName="check-in" endName="check-out">
    <DateRangeField.Input range="start" aria-label="Check-in" />
    <span aria-hidden="true">–</span>
    <DateRangeField.Input range="end" aria-label="Check-out" />
</DateRangeField.Root>;

Props

Every part also takes what the primitive contract gives. Vue binds the value as v-model:value with @value-change; Angular as [(value)] with (valueChangeDetails) ({ value, details }).

Root

proptypedefaultdescription
valueDateRangeFieldValue | nullthe range, controlled
defaultValueDateRangeFieldValue | nullnullthe initial range, uncontrolled
onValueChange(value, details: { reason, event }) => voidevery change of the range
granularity"day" | "hour" | "minute" | "second""day"the smallest segment; a time granularity makes both ends PlainDateTimes
placeholderValuePlainDate | PlainDateTimetoday at midnightwhat an arrow on an empty segment starts from
hourCycle12 | 24the locale'sa time granularity's clock
minPlainDate | PlainDateTimeends before it are invalid
maxPlainDate | PlainDateTimeends after it are invalid
isDateUnavailable(date: PlainDate) => booleana range whose start or end is unavailable is invalid
localestringthe document's langthe segments' order, digits and names
calendarCalendarSystemthe ISO calendara calendar system: the segments show and edit its year, month (up to 13) and day, and an era where it has several; values stay ISO
timeZoneTimeZonea 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]
hideTimeZonebooleanfalseleaves 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
requiredbooleanfalseboth hidden inputs are required
readOnlybooleanfalsefocusable and submitted, but nothing changes it
disabledbooleanfalseno segment is focusable, nothing is submitted
startNamestringthe start's hidden input name
endNamestringthe end's hidden input name

Input

proptypedefaultdescription
range"start" | "end"requiredthe end whose segments it holds

Its children: a function of each segment (Vue: the default slot's { segment }; Angular: @for over segments()); with none, every segment with its own text. Name it with aria-label.

Segment

proptypedefaultdescription
segmentDateSegmentrequiredone of the Input's segments

State and part attributes

As DateField's, named date-range-field-*; the Input and the hidden inputs add data-range="start" / "end", and every part is data-invalid while the range is.

Keyboard

As DateField's, across both ends: digits move on into the end, Backspace moves back into the start, ArrowLeft and ArrowRight cross them.

Exports

entryexports
@fragiola/primitives-react/date-range-fieldChangeDetails, ChangeReason, DateFieldInputProps, DateFieldSegmentProps, DateFieldSegmentState, DateFieldState, DateFieldValue, DateRange, DateRangeField, DateRangeFieldInputProps, DateRangeFieldRootProps, DateRangeFieldRootSharedProps, DateRangeFieldValue, DateSegment, PlainDate, PlainDateTime, PlainTime, RangeEnd, RenderProp, SegmentGranularity, SegmentType
@fragiola/primitives-vue/date-range-fieldChangeDetails, ChangeReason, DateFieldInputSlots, DateFieldSegmentProps, DateFieldSegmentState, DateFieldState, DateFieldValue, DateRange, DateRangeField, DateRangeFieldInputProps, DateRangeFieldRootEmits, DateRangeFieldRootProps, DateRangeFieldRootSharedProps, DateRangeFieldValue, DateSegment, PlainDate, PlainDateTime, PlainTime, RangeEnd, RenderSlotProps, SegmentGranularity, SegmentType
@fragiola/primitives-angular/date-range-fieldChangeDetails, ChangeReason, composeRange, DATE_RANGE_FIELD, DateFieldSegment, DateFieldSegmentState, DateFieldState, DateFieldValue, DateRange, DateRangeFieldInput, DateRangeFieldInputs, DateRangeFieldRoot, DateRangeFieldRootBase, DateRangeFieldRootState, DateRangeFieldValue, DateSegment, edgeOf, FieldRange, isRangeInvalid, PlainDate, PlainDateTime, PlainTime, RangeEnd, RangeEndParts, RangeGroups, rangeIso, SegmentGranularity, SegmentType, ValueChangeEvent