Fluixi UI
GitHub ↗

Examples

Loading preview…

date-field

Accessible, internationalised segmented date & time input.


A segmented date field — each part (month, day, year, and optionally hour, minute, second, AM/PM) is an individually focusable spinbutton, not a masked string. The segment order, separators, calendar system and hour cycle all follow the locale. Each segment steps with the arrow keys, accepts typed digits, and clears with Backspace. Powered by @fluixi/date-core.

Installation

pnpm add @fluixi/date-field

Usage

import { DateField, DateFieldLabel, DateInput } from '@fluixi/date-field';
import { today, getLocalTimeZone } from '@fluixi/date-core';

<DateField locale="en-US" defaultValue={today(getLocalTimeZone())} onChange={console.log}>
  <DateFieldLabel>Due date</DateFieldLabel>
  <DateInput />
</DateField>

Date & time

Add time segments with granularity; force a 12- or 24-hour clock with hourCycle (defaults to the locale's convention).

<DateField locale="en-US" granularity="minute" hourCycle={12}>
  <DateInput />
</DateField>

Time field

TimeField is the same segmented input over a bare Time value (hour / minute, optionally second, plus AM/PM on a 12-hour clock). It reuses the same segment parts via TimeInput / TimeFieldLabel.

import { TimeField, TimeFieldLabel, TimeInput } from '@fluixi/date-field';
import { Time } from '@fluixi/date-core';

<TimeField locale="en-US" hourCycle={12} defaultValue={new Time(9, 30)} onChange={console.log}>
  <TimeFieldLabel>Start time</TimeFieldLabel>
  <TimeInput />
</TimeField>

Props: locale, value / defaultValue / onChange (a Time), granularity ('hour' | 'minute' | 'second', default 'minute'), hourCycle, placeholderValue, isDisabled, isReadOnly, isRequired, name.

Forms

Pass name to emit a hidden input carrying the ISO value for native submission (YYYY-MM-DD for a date field, HH:MM:SS for a time field).

Props (DateField)

Prop Type Default Description
locale string BCP-47 locale; drives segment order, separators, calendar and hour cycle.
value DateValue | null Controlled value.
defaultValue DateValue | null Initial uncontrolled value.
onChange (value) => void Fired when a complete value is entered or a segment cleared.
granularity 'day' | 'hour' | 'minute' | 'second' 'day' Precision; adds time segments beyond day.
hourCycle 12 | 24 locale Force a clock convention.
placeholderValue DateValue today Starting field values before entry.
minValue / maxValue DateValue Bounds used for validation.
isDisabled boolean false Disables the field.
isReadOnly boolean false Value fixed but focusable.
isRequired boolean false Marks the field required.
name string Emits a hidden input with the ISO value.

Parts

Component Element Description
DateField div Root; owns state and provides context.
DateFieldLabel span Label linked to the segment group.
DateInput div[role=group] Segment container; renders the segments.

Segments render as div[role=spinbutton] with data-date-field-segment="<type>" and data-placeholder while empty.

Keyboard

Key Action
/ Increment / decrement the focused segment (wraps)
Page Up / Page Down Larger step
Home / End Jump to the segment's min / max
/ Move between segments
09 Type a value; auto-advances when full
A / P Set AM / PM (day-period segment)
Backspace Clear the focused segment