Time picker
Takes a typed time or one from a list, alone or with a day.
Book a client demo
Installation
npm i @uisatin/uiimport { TimePicker, type TimeValue } from '@uisatin/ui/time-picker'About 59.2 kB of JavaScript, minified and gzipped, with what it imports (React aside). The stylesheet is one file for every component.
npx shadcn@latest add https://uisatin.dev/r/time-picker.json https://uisatin.dev/r/form.jsonAdds time-picker.tsx, button.tsx, date-picker.tsx, dropdown.tsx, form.tsx, form-field.tsx, kbd.tsx, labels.tsx, pointer-modality.tsx, select.tsx and spinner.tsx to components/ui and installs iconoir-react and radix-ui.
First time with Satin? Set it up once, styles and fonts included, with the installation guide.
API Reference
TimePicker is a text field with the Input skin that reads a typed time ("930", "9:30pm", "1430") or opens a list of times under it; its value is { hours, minutes }, null when cleared or typed wrong. DateTimePicker is the Date picker field opening the Calendar with a column of times beside it; its value is a Date. TimeList and DateTimePickerPanel are the list and the panel on their own. Times are written in the dateLocale label, 12- or 24-hour as that locale writes them; with name, a hidden input submits HH:mm or YYYY-MM-DDTHH:mm.
| Prop | Type | Default |
|---|---|---|
TimePicker.value | { hours: number, minutes: number }null | — |
TimePicker.defaultValue | TimeValuenull | — |
TimePicker.onValueChange | (value: TimeValue | null) => void | — |
TimePicker.min / max | TimeValue | — |
DateTimePicker.value | Datenull | — |
DateTimePicker.defaultValue | Datenull | — |
DateTimePicker.onValueChange | (value: Date) => void | — |
DateTimePicker.min / max | Date | — |
DateTimePicker.minTime / maxTime | TimeValue | — |
step | number | 15 |
isTimeDisabled | (time: TimeValue, day?: Date | null) => boolean | — |
format | "12h""24h" | the locale's |
open / defaultOpen | boolean | — |
onOpenChange | (open: boolean) => void | — |
name | string | — |
label / hint / error | ReactNode | — |
className | string | — |
ref | Ref<HTMLInputElement> | — |
...props | ComponentProps<'input'>Other attributes go to <input> | — |
Accessibility
TimePicker's field is a combobox named by its label and described by a format hint ("Type a time like 2:30 PM", timeHint in SatinLabels) and by the hint or error. Focus stays in it while the listbox of times is open; aria-activedescendant follows the highlighted time. Each time is an option: the picked one aria-selected, unavailable ones aria-disabled. Typed text that isn't an available time sets aria-invalid and says why under the field (timeInvalid, timeUnavailable). The chevron, "Show times", is out of the tab order. DateTimePicker's field is a button that opens the Calendar (as on Date picker) with the times as a listbox named "Time"; picking a day with no time yet moves focus to the times. A pick there sets the value and leaves the panel open, and the focus where it was, so the change is heard as the time becoming selected.
| Key | Action |
|---|---|
| ↓or↑ | On the field: opens the list on the picked time, then moves to the next or previous available time. |
| Alt+↓orAlt+↑ | Opens or closes the list without moving the highlight. |
| Page DownorPage Up | Moves an hour on or back. |
| HomeorEnd | In TimeList and the date-and-time panel: the first or last available time. In the field they move the caret. |
| 0–9orAorP | Type-ahead: the list jumps to the time typed so far ("14", "2p"). In a TimeList a second's pause starts over. |
| Enter | Picks the highlighted time once the arrows or the pointer moved there and closes the list; otherwise reads what was typed ("930", "9:30pm"). In a TimeList, Space picks too. In the date-and-time panel a pick leaves it open; Enter on the time already picked closes it and returns focus to the field. |
| Esc | Closes the list and leaves focus in the field (the date-and-time panel returns it to the field). With the list closed, puts back the time the field showed. |
| Tab | Reads what was typed, closes the list and moves on. |
Something wrong or missing on this page?
Report a problemSuggest an improvement