Fragiola

API: components

DateField

A date, or a date and a time, typed in segments, each an APG spinbutton, in the locale's order, with forms and Field support, in each framework.

A date typed in parts: a month, a day and a year, each a spinbutton the user types digits into or steps with the arrows, in the order and with the digits of the locale. With a time granularity it is a date and a time. It works in a native <form> and in a Field. The APG has no date field and Base UI has no date component, so each segment is the APG spinbutton, the closest pattern, with React Aria's DateField as the behaviour reference where the APG says nothing (the behaviour rule). TimeField is the same anatomy over a time.

Birth date
Gallery

Behaviour

  • Segments from Intl: the order, the literals between the segments, the hour cycle, the digits (Arabic-Indic in ar-EG) and each segment's name ("month", "Monat") come from Intl.DateTimeFormat#formatToParts and Intl.DisplayNames: the one exception to "no text", as the calendars', and you can replace each. A segment with no value shows one – per digit.
  • Value: a PlainDate ({ year, month, day }), or a PlainDateTime with a time granularity, set only once every segment is; null until then. onValueChange reports input-change, input-clear, keyboard or none (a reset).
  • Typing: a digit continues the segment's digits and moves on once no further digit fits (4 in a month, 12, a year's fourth digit); a number out of range starts again; the day period takes the first letter of AM or PM. Backspace and Delete erase a digit, then move back. A year is typed as written, in full: 26 is the year 26.
  • Keys: ArrowUp and ArrowDown step and wrap within the segment, Page Up and Page Down by a larger step, Home and End to its edges, ArrowLeft and ArrowRight to the segment on that side of the screen; each segment is a tab stop.
  • Validation: a value before min, after max or unavailable (isDateUnavailable) is invalid (data-invalid, aria-invalid).
  • Forms: a hidden native date (or datetime-local) input submits the ISO value, with min and max; required refuses an empty field; a reset returns to defaultValue.
  • Calendar systems: with calendar={persian} (from @fragiola/primitives/calendar-systems) the segments show and edit the system's year, month (up to 13 in a Hebrew leap year) and day; where the system has several eras (Japanese, ROC) the era is a segment too, stepped with the arrows or typed by its first letters. The value and the form stay ISO.
  • Time zones: with timeZone={timeZone("America/New_York")} (from @fragiola/primitives/time-zone) the value is a ZonedDateTime in that zone; a time granularity shows the zone's name ("EST", "EDT" as the value crosses the change), a segment that is read, not edited (hideTimeZone leaves it out). The segments keep the wall time typed, resolved with disambiguation where a DST change skips or repeats it (2:30 AM on a spring-forward night is 3:30 AM by default). The hidden input is then type="text" and submits 2026-11-01T01:30-05:00[America/New_York]: required still works, min and max mark the field invalid but have no native message.
Meeting across time zones
Gallery
  • Right to left: the segments keep the order the locale's text has (a numeric segment is one left-to-right run); lay them out inline, not as flex items.

Anatomy

partelementdata-primitives-partrole
Rootdivdate-field-rootholds the value; renders the hidden input after it
Inputdivdate-field-inputgroup of the segments
Segmentspandate-field-segmentspinbutton, or a literal hidden from assistive technology
(hidden input)input type="date"date-field-hidden-inputwhat the form submits

Usage

import { DateField } from "@fragiola/primitives-react/date-field";
import { Field } from "@fragiola/primitives-react/field";

<Field.Root name="birth-date">
    <Field.Label>Birth date</Field.Label>
    <DateField.Root value={date} onValueChange={setDate} max={today} required>
        <DateField.Input>
            {(segment) => <DateField.Segment key={segment.index} segment={segment} />}
        </DateField.Input>
    </DateField.Root>
</Field.Root>;

Props

Every part also takes what the primitive contract gives: render (Vue: as and the render slot), a class and a style, a ref, and any attribute, which it forwards. Vue binds the value as v-model:value with @value-change; Angular as [(value)] with (valueChangeDetails) ({ value, details }).

Root

proptypedefaultdescription
valuePlainDate | PlainDateTime | nullthe value, controlled
defaultValuePlainDate | PlainDateTime | nullnullthe initial value, uncontrolled
onValueChange(value, details: { reason, event }) => voidevery change of the value
granularity"day" | "hour" | "minute" | "second""day"the smallest segment; a time granularity makes the value a PlainDateTime
placeholderValuePlainDate | PlainDateTimetoday at midnightwhat an arrow on an empty segment starts from
hourCycle12 | 24the locale'sa time granularity's clock
minPlainDate | PlainDateTimevalues before it are invalid
maxPlainDate | PlainDateTimevalues after it are invalid
isDateUnavailable(date: PlainDate) => booleanan unavailable date 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
requiredbooleanfalsethe hidden input is required
readOnlybooleanfalsefocusable and submitted, but nothing changes it
disabledbooleanfalseno segment is focusable, nothing is submitted
namestringthe hidden input's name (a Field's wins)

Input

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.

Segment

proptypedefaultdescription
segmentDateSegmentrequiredone of the Input's segments: { type, index, text, editable, placeholder, value, min, max, valueText, label }

Its content replaces the segment's text; your aria-label replaces its name.

State and part attributes

Every part carries data-disabled, data-readonly, data-required, data-invalid and, inside a Field, the Field's state.

partattributes
Inputrole="group"; inside a Field, aria-labelledby and aria-describedby
Segment (editable)role="spinbutton", tabindex="0", aria-label, aria-valuenow, aria-valuetext, aria-valuemin, aria-valuemax, contenteditable, inputmode, data-type, data-placeholder
Segment (literal)aria-hidden="true", data-type="literal"
Segment (time zone name)data-type="timeZoneName"; no role, not hidden: read as part of the field

Keyboard

keydoes
digitsfill the segment, then move on
ArrowUp, ArrowDownstep by one, wrapping within the segment
Page Up, Page Downstep by a larger amount (year 5, month 2, day 7, hour 2, minutes 15)
Home, Endthe segment's minimum, maximum
ArrowLeft, ArrowRightthe segment on that side
Backspace, Deleteerase a digit; on an empty segment, move back
Tabthe next segment, then out of the field

Exports

entryexports
@fragiola/primitives-react/date-fieldChangeDetails, ChangeReason, DateField, DateFieldInputProps, DateFieldRootProps, DateFieldRootSharedProps, DateFieldSegmentProps, DateFieldSegmentState, DateFieldState, DateFieldValue, DateSegment, PlainDate, PlainDateTime, PlainTime, RenderProp, SegmentGranularity, SegmentType
@fragiola/primitives-vue/date-fieldChangeDetails, ChangeReason, DateField, DateFieldInputSlots, DateFieldRootEmits, DateFieldRootProps, DateFieldRootSharedProps, DateFieldSegmentProps, DateFieldSegmentState, DateFieldState, DateFieldValue, DateSegment, PlainDate, PlainDateTime, PlainTime, RenderSlotProps, SegmentGranularity, SegmentType
@fragiola/primitives-angular/date-fieldboundIso, ChangeDetails, ChangeReason, compareValues, composeSegments, DATE_FIELD, DateFieldComponent, DateFieldData, DateFieldInput, DateFieldInputs, DateFieldParts, DateFieldRoot, DateFieldRootBase, DateFieldRootState, DateFieldSegment, DateFieldSegmentState, DateFieldState, DateFieldSystemInputs, DateFieldValue, DateSegment, documentLocale, editReason, FieldValue, hiddenType, isoOf, isOutOfRange, PlainDate, PlainDateTime, PlainTime, SegmentEditKind, SegmentGranularity, SegmentGroup, SegmentGroupOwner, SegmentType, stateData, systemFormat, ValueChangeEvent