Time Field
Time typed segment by segment, 24-hour or AM/PM. Free, MIT · Forms and input › Date and time
A time typed in place, segment by segment: hour, minute and, on a 12-hour clock, AM/PM, in the locale's order (React Aria's TimeField). Digits fill a segment and move on; ArrowUp / ArrowDown step it; "a" / "p" set the period. Each segment is a spinbutton for screen readers and opens the number keyboard on a phone.
Installation
npx valyro-cli@latest add time-field
npx shadcn@latest add https://valyro.xyz/r/time-field.json
npm install valyro-ui
import 'valyro-ui/styles.css';
import { TimeField } from 'valyro-ui';
Props
| Prop | Type | Default | |
|---|---|---|---|
value | string | null | 24-hour "HH:mm". | |
defaultValue | string | null | null | Initial value when uncontrolled. |
onValueChange | (value: string | null) => void | Called with "HH:mm" once every segment is filled, and with null when one is cleared. | |
hourCycle | 12 | 24 | 12 (with an AM/PM segment) or 24. Defaults to the locale's clock: 12 in en-US, 24 in most of Europe. | |
locale | string | Order of the segments, the digits and the AM/PM names. Defaults to the ThemeProvider locale, then the browser's. | |
size | 'sm' | 'md' | 'lg' | 'md' | Field height and text size. |
disabled | boolean | false | Takes the segments out of the Tab order and leaves the time out of form data. |
readOnly | boolean | false | Focusable and readable, not editable. |
invalid | boolean | false | Danger border and aria-invalid. Also shown after a submit attempt while a required time is missing. |
name | string | Submits the time with the surrounding form as 24-hour HH:mm (empty when incomplete). | |
required | boolean | Blocks native form submission while the time is incomplete; aria-required on the segments. | |
icon | ReactNode | <ClockIcon /> | Icon before the segments; null for none. Default: a clock. |
labels | Partial<TimeFieldLabels> | Overrides for the built-in English text; keys left out keep their defaults. |
Related components
- Date Picker — Date selection
- Date Range Picker — Date range selection
- Date Field — Date typed segment by segment in the locale order
- Time Picker — Time selection
- Wheel Picker — iOS-style picker wheel: momentum, 3D cylinder, date and time presets
- Date Of Birth Input — Date of birth as three selects in locale order
- Text Input — Text fields
- Textarea — Multiline text input
- Search Input — Search field
- Mentions Input — Text with @mentions and #tags, async suggestions
- Tags Input — Tag entry
- Select — Pick one option from a list
Previous: Time Picker · Next: Wheel Picker · All Forms and input