Skip to content

Early previewhamur is not on npm yet. The components are being built in the open, follow along on GitHub.

UIComponentsReact

Time Field

A time of day typed in segments, hour, minute, optionally seconds and a day period, each one a spinbutton, with a button that clears them all.

Built on the headless Time Field.See its API in Docs

Rendered by React 19.3.1

time-field.tsx

Installation

npx shadcn@4.23.0 add https://hamur.dev/r/react/time-field.json

It also adds utils, button. The app needs its setup first: Installation.

Usage

Put a TimeFieldInput and a TimeFieldClear inside TimeField, and a FieldLabel above it. Without children, TimeFieldInput renders every segment, styled; pass your own children to place them yourself, drawing each with TimeFieldSegment. Values are strings such as 14:30, 14:30:15 or 14:30:15.250. hourCycle chooses 12 or 24 hours and granularity how fine the segments go. The keys, the typing, the limits and the form value come from the headless Time Field.

import {
  TimeField,
  TimeFieldClear,
  TimeFieldInput,
  TimeFieldSegment,
} from '@/components/ui/time-field'

Examples

Default

A start time under its label in 12 hours, with a Clear button.

Its preview and code are at the top of the page.

It looks as Date Field does: Input's box, the focused segment filled, an empty one dimmed to its placeholder and an invalid one underlined with a dashed line. This item takes Base UI's component ID as its slug and one name per Base UI part.

API reference

The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Time Field's API reference.