Molecules · Time field
Time field
A time of day, an add-on to the date pickers. Hours and minutes are segments you type into or step with the arrow keys, like DateField; the clock button opens a list of times every step minutes. With a 12-hour clock there is an AM/PM segment. The value is 'HH:MM' on a 24-hour clock whatever is shown. Put it next to a DatePicker for a date and a time.
- Best for
- A pickup slot, a meeting start, a shift.
- Not for
- A duration: Input with a unit.
This page as Markdown, a plain-text copy for a coding agent (an AI tool that writes code).
Examples
Default, 24-hour
Code
tsx
<div className="w-36"> <TimeField label="Start time" hourCycle={24} /></div>12-hour, with AM and PM
Code
tsx
<div className="w-40"> <TimeField label="Call time" hourCycle={12} defaultValue="14:30" /></div>With a DatePicker: a date and a time
11142026
0930AM
Code
tsx
function DateAndTime() { const [date, setDate] = useState('2026-11-14') const [time, setTime] = useState('09:30') return ( <div className="flex w-full max-w-md flex-col gap-3"> <div className="grid gap-3 sm:grid-cols-[1fr_9rem]"> <FormField label="Pickup date"> <DatePicker value={date} onValueChange={setDate} /> </FormField> <FormField label="Pickup time"> <TimeField value={time} onValueChange={setTime} step={15} min="08:00" max="18:00" /> </FormField> </div> <span className="font-mono text-xs text-[var(--color-text-secondary)]"> {date && time ? `${date}T${time}` : 'Pick a date and a time'} </span> </div> )}<DateAndTime />Anatomy
| Part | What it is |
|---|---|
| Field | A group named by the label: Hour, Minute and, on a 12-hour clock, AM or PM, each a spinbutton. |
| Clock button | A ghost IconButton. Its name includes the time: "Choose time, 14:30". |
| Time list | A listbox of times between min and max, every step minutes. It opens on the picked time, or the next slot after now. |
Props
- labelstring
- Names the field. Leave it out inside a FormField, which sets it from its own label. Outside one it is required, and `division-ds check` flags a missing one.
- valuestring ('HH:MM' | '')
- Controlled value, 24-hour.
- defaultValuestringDefault ''
- Starting value when the field holds it itself.
- onValueChange(value: string) => void
- Fires with a whole time, or '' when emptied.
- hourCycle12 | 24
- 12 adds an AM/PM segment. The value stays 24-hour. Defaults to the locale's clock.
- stepnumberDefault 30
- Minutes between the times in the list. It only spaces the list: a typed time between steps (09:07) is kept as typed. Check it yourself if it must fall on a step.
- minstring
- Earliest time, 'HH:MM'. Earlier times are left out of the list; typing one marks the field invalid.
- maxstring
- Latest time, 'HH:MM'.
- showSlotsbooleanDefault true
- Shows the clock button and its list.
- localestring
- Decides the default clock. Defaults to the browser's.
- disabledbooleanDefault false
- Disables the field and the button.
- invalidboolean
- Marks the field invalid. FormField sets it.
- requiredboolean
- Marks the field required. FormField sets it.
- namestring
- Submits the 'HH:MM' value with a form.
- idstring
- The field's id. FormField sets it.
- aria-describedbystring
- The ids of the help and error text. FormField sets it.
- classNamestring
- Combined with the field's classes.
- refRef<HTMLDivElement>
- The field's group element.
- hourCycleFor()(locale?: string) => 12 | 24
- The locale's own clock.
Keyboard
| Keys | Result |
|---|---|
| 0–9 | Types the hour or minute and moves on once it is full. |
| AP | On the AM/PM segment, sets AM or PM. |
| ↑↓ | In the field: one more or one less. In the list: the next or previous time. |
| ←→ | The previous or next segment. |
| Page UpPage Down | In the list: six times earlier or later. |
| EnterSpace | In the list: picks the time and closes it. |
| Esc | Closes the list without a change. |
Do and don't
Do
- Set step to the real booking grid, such as 15 for 15-minute slots.
- Store the value with its date and the time zone it means, separately.
Don't
- Don't parse 'HH:MM' with new Date(): keep it a string until you combine it with a date and a zone.