ValyroUI Русская версия

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

PropTypeDefault
valuestring | null24-hour "HH:mm".
defaultValuestring | nullnullInitial value when uncontrolled.
onValueChange(value: string | null) => voidCalled with "HH:mm" once every segment is filled, and with null when one is cleared.
hourCycle12 | 2412 (with an AM/PM segment) or 24. Defaults to the locale's clock: 12 in en-US, 24 in most of Europe.
localestringOrder 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.
disabledbooleanfalseTakes the segments out of the Tab order and leaves the time out of form data.
readOnlybooleanfalseFocusable and readable, not editable.
invalidbooleanfalseDanger border and aria-invalid. Also shown after a submit attempt while a required time is missing.
namestringSubmits the time with the surrounding form as 24-hour HH:mm (empty when incomplete).
requiredbooleanBlocks native form submission while the time is incomplete; aria-required on the segments.
iconReactNode<ClockIcon />Icon before the segments; null for none. Default: a clock.
labelsPartial<TimeFieldLabels>Overrides for the built-in English text; keys left out keep their defaults.

Related components

Previous: Time Picker · Next: Wheel Picker · All Forms and input