Date and time
TimePicker
Type 21 to filter the slots
Value: 10:00
Slots every 15 minutes
Value: empty
When to use
- The user can quickly type an exact time or pick a convenient slot.
- The time is stored separately from the calendar date, for example in
DateTimePicker.
When not to use
- For a complete point in time that includes a date, use
DateTimePicker. - For a free-form string that is not necessarily a time, use
TextControl.
Minimal example
<TimePicker value={time} onChange={setTime} step={30} aria-label="Publication time" />Public API
value?: string | null;onChange(time: string)is required;stepdefaults to 30 minutes.hourCycle?: 12 | 24is the hour cycle of the field and the list; the default is24(14:30). With12, the field and the slots show2:30 PM; you can type230por2:30 PM, and a typed 24-hour time (14:30) is accepted too. This affects only display and input:valueandonChangestayHH:MM. TheAMandPMlabels and theh:mm AMmask come from the catalog (timePicker.am,timePicker.pm,timePicker.placeholder12). If no day period is typed, the day period of the previous value is used, andAMfor an empty field.placeholderandaria-labelcome from the message catalog (timePicker.placeholder,timePicker.label): without a provider they areHH:MMand "Time", with@olddevs/ui/locales/ru—ЧЧ:ММand "Время". A prop overrides the catalog string individually.disabledandclassNameare available.invalidshows the field in an error state: the line under the time turns red (including when focused), andaria-invalidis set on the field. The validation rule stays with the consumer. Inside aFormFieldwitherrorthe prop is not needed: the flag comes from the form, as it does forTextControlandNumberInput, and an explicitinvalid={false}clears it. The form's hint and error are also announced with the field — theiridgoes intoaria-describedby.upcomingSlots(step, now)is a public utility that returns the full 24-hour list, starting from the nearest future slot. It is useful for presentation, but it is not a UI component.
Accessibility and keyboard
- The input has combobox semantics; focus stays in the field, and the list reports the active slot through
aria-activedescendant. - The Down Arrow and Up Arrow keys move through the slots, Enter picks a slot or confirms the typed text, Escape closes the list and keeps bubbling up to the parent overlay.
- Sources:
src/components/date-time/TimePicker.tsx,src/components/date-time/TimePicker.stories.tsx,tests/timepicker.test.tsx.
TypeScript types
TimePickerProps
Prop
Type