Time Field
A time, chosen from a stepped list or typed in whatever shorthand comes naturally.
09:30
Installation
npx shadcn@latest add https://qure-ui.qure.ai/r/time-field.jsonUsage
import { TimeField, parseTime } from "@/components/ui/time-field"const [time, setTime] = React.useState<string | null>("09:30")
<TimeField value={time} onValueChange={setTime} aria-label="Time" />The value is a "HH:mm" string in 24-hour form, or null. A string rather than a Date,
because a time without a date is not a moment — attaching one silently invents a day.
Like Input, the field fills its container rather than sizing itself,
so wrap it to set a width — w-32 fits HH:mm with the clock and clear affordances.
Typing is supported here
| 9 | 09:00 |
| 930 | 09:30 |
| 9.30 | 09:30 |
| 9:5 | 09:05 |
| 1430 | 14:30 |
| 9pm | 21:00 |
| 11:59 PM | 23:59 |
This is the opposite decision to DatePicker, and the difference
is real rather than inconsistent. 03/04 is two different days depending on where the reader
grew up; 14:30 is 14:30 everywhere. There is no ambiguity to get wrong — only shorthand to
expand, and people type 9, 930, 9.30 and 9pm expecting all of them to work.
| Typed | Read as |
|---|---|
9, 09 | 09:00 |
930, 0930, 9.30, 9:30 | 09:30 |
9:5 | 09:05 |
1430 | 14:30 |
9pm, 9 PM | 21:00 |
12am | 00:00 |
parseTime is exported, so the same rules can validate a form on submit rather than being
reimplemented next to it.
The list is a convenience, not a constraint. 07:20 is a real time even when the list steps by fifteen minutes. A field that refuses it is a field people work around by writing the time into a notes box, where nothing can read it.
Something unreadable is left in the box rather than silently discarded — clearing what someone typed is how a field loses an appointment time without ever saying which one. The field marks itself invalid instead.
Stepping and bounds
<TimeField step={30} min="08:00" max="18:00" />step sets the spacing of the suggestions, min and max trim them. None of the three
restrict what can be typed — they shape the list, which is the part that is a convenience.
With a date
8/14/2026, 2:00:00 PM
Two controls rather than one. A combined datetime picker makes changing just the time mean re-choosing the date, which is the more common of the two edits.
Twelve-hour display
<TimeField hour12 />Only the suggestions change. The value stays 24-hour, so nothing downstream has to know how it was displayed.
API Reference
Prop
Type