Fragiola

Dates

Time Range Field

A start and an end time typed in segments, in one field row.

npx shadcn@latest add @fragiola/time-range-field
Time Range Field
Gallery

A time range field types two times in one row, as the Date Range Field types two dates: one sequence across the ends, each end an Input with its own name, and an end before the start makes the range invalid. Its segments are the Time Field's.

Bases

Primitives-backed. Base UI has no time range field, so this is one shared file (ui/time-range-field.tsx) that wraps Fragiola Primitives' TimeRangeField on both bases, and the item depends on @fragiola/[email protected] on both. It follows the direction of the base's DirectionProvider on Base UI too, and dir="rtl" without one.

On Base UI, the registry's Field is Base UI's, and a Fragiola Primitives control does not join it: name each end with aria-labelledby (the label's id and the end's own id, so each end keeps its aria-label, as the example does), and pass name, disabled and required to the Root. On Fragiola Primitives it is also a Field control: the label names the group, a press on the label focuses the first segment, and the Field's description, disabled and validation reach it.

Invalid. The range's own invalid state (data-invalid on its parts) turns its segments palette-danger by inheritance; the row's stroke follows when the Field itself is invalid — pass invalid to Field.Root, which works on both bases.

Parts

The Date Range Field's parts, named time-range-field-*, with its own Root (primitive TimeRangeField.Root).

On this page