Skip to contentKino
Skip to Content

Time input

A time typed one segment at a time on the locale's clock, where a highlight glides between the segments and each number rolls to its new value.

npx shadcn add https://kinoui.com/r/time-input.json
Share on

Examples

Default

Type the time, or step each segment with the arrow keys: the highlight follows you and each number rolls to its new value, as in the Date input.

Locale

locale sets the clock, the order and the names of AM and PM; without it, the field follows the browser’s language.

Hour cycle

hourCycle sets a 12-hour or a 24-hour clock whatever the locale; the value is a 24-hour time either way.

Granularity

granularity='second' adds a seconds segment, and the value becomes HH:mm:ss. granularity='hour' leaves the minutes out, and the value is HH:00.

Any time from 9:00 AM to 5:00 PM.

Min and max

A time outside min and max shows as invalid, and a form won’t submit it. A min later than max runs over midnight.

Controlled

Hold the value with value and onValueChange; a value set from outside rolls each number the way it went.

Installation

npx shadcn@latest add https://kinoui.com/r/time-input.json
Files
lib/dates.tslib/segments.tslib/refs.tslib/field-control.tsxlib/segment-field.tsxlib/reduce-motion.tscomponents/kino/input.tsxlib/resize.tslib/run-progress.tslib/highlight.tslib/roll.tsxlib/scroll.tslib/segmented-input.tsxcomponents/kino/time-input.tsx
Packages
@base-ui/react

New to Kino? Installation covers what your project needs first and the @kino namespace.

API reference

Props

PropTypeDefaultDescription
defaultValuestringnullNoneThe time at first, as a 24-hour HH:mm or HH:mm:ss, when you leave the state to the field.
valuestringnullNoneThe time as a 24-hour HH:mm, or HH:mm:ss with seconds, or null when it is empty, when you hold the state.
onValueChange(value: string | null) => voidNoneCalled once every segment is filled, and with null once every segment is empty. A half-typed time calls nothing.
localestringNoneThe clock, order and names of AM and PM. The browser’s language by default.
hourCycle1224NoneA 12-hour clock with AM and PM, or a 24-hour one. The locale’s by default.
granularity'hour''minute''second''minute'The smallest unit shown. To the hour the value is HH:00; to the second, HH:mm:ss.
minstringNoneThe earliest time allowed, as HH:mm. Later than max, the range runs over midnight.
maxstringNoneThe latest time allowed, as HH:mm.
namestringNoneThe name the form sends the time under, as HH:mm. A Field’s name by default.
requiredbooleanNoneA form won’t submit it empty.
disabledbooleanNoneTurns every segment off.
readOnlybooleanNoneShows the time without letting it change.

Accessibility

  • Each segment is a spin button with its own name (hour, minute, AM/PM) and the field’s label: the arrow keys step it and wrap, the hour within AM or PM, Page Up and Page Down step 2 hours or 15 minutes, and Home and End go to its first and last value.
  • A segment moves on as soon as no other digit could follow, a separator key moves on, a or p picks AM or PM in any language, and Backspace on an empty segment goes back. Left and right arrows follow the screen, in right-to-left pages too.
  • Pasting 14:30 or 2:30 PM fills every segment.
  • A time out of range is invalid for the form and shows the invalid icon, so it never relies on colour alone.
  • When the system asks for less motion, the highlight moves in place and the numbers crossfade.