Skip to content

HyDateField

Usage examples on this page are written for Lit / plain HTML (<hy-date-field>). The same component ships as HyDateField in @whitespaceux/harmony-react (native React 19), with typed wrappers for Angular, Solid, Svelte, and Vue. The API reference below applies to all frameworks.

A locale-aware segmented date (and optional time) input. Each unit (month / day / year, plus hour / minute in datetime mode) is an arrow-adjustable, type-to-edit spinbutton — the keyboard-first, screen- reader-friendly replacement for a readonly trigger. No calendar; compose with hy-date-picker for the popover.

Independently form-associated — usable standalone with its own name / value and form-control surface (hy-date-picker composes it rather than re-implementing).

Value is ISO YYYY-MM-DD (date) or YYYY-MM-DDTHH:MM (datetime). Segment order, separators, and 12/24h come from the resolved locale via Intl.

Examples

html
<hy-date-field label="Start date" value="2026-03-07"></hy-date-field>
<hy-date-field type="datetime" label="Starts at"></hy-date-field>

API

Properties

PropertyAttributeTypeDefaultDescription
valuevaluestring''ISO value: YYYY-MM-DD (date) or YYYY-MM-DDTHH:MM (datetime).
typetype'date' | 'datetime''date'date (default) or datetime (adds hour/minute segments).
minminstring | undefined
maxmaxstring | undefined
localelocalestring | undefined
labellabelstring''
helpTexthelp-textstring''
errorMessageerror-messagestring''
invalidinvalidbooleanfalse
disableddisabledbooleanfalse
namenamestring''
sizesize'small' | 'medium' | 'large''medium'
widthwidthstring | undefined
autofocusautofocusbooleanfalse
formHTMLFormElement | null
validityValidityState

Events

EventDetailDescription
inputFires on each segment edit that yields a complete valid value.
changeFires on blur / Enter once all segments form a valid value.

CSS Parts

PartDescription
baseOuter wrapper (label, field, helper/error)
labelThe visible label
fieldThe segmented input row
segmentA single editable segment
helper-textHelper text
error-messageError message when invalid

CSS Custom Properties

PropertyDescription
--hy-date-field-height-smSmall-size outer height (default var(--hy-control-height-sm))
--hy-date-field-height-mdMedium-size outer height (default var(--hy-control-height-md))
--hy-date-field-height-lgLarge-size outer height (default var(--hy-control-height-lg))

Built with Lit. Documented with VitePress.