Forms
TimePicker
Free25.0 KB gzippedA time field: type a time in almost any form ("2:30 pm", "1430", "230p", "14h30", the locale's own format), or pick one from a list of times step minutes apart. Built on Combobox, so the list follows the WAI-ARIA combobox pattern: ArrowDown opens it on the selected time, arrows move, Enter picks, Escape closes, and typing filters it.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Arrow Down, Arrow Up, Enter and 1 more · Full report
Import
import { TimePicker } from "@vjdesigns/vjdesigns-ui";
Importing only TimePicker adds about 25.0 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Basic
Type a time in almost any form ("2:30 pm", "1430", "230p"), or press Arrow Down to pick from times step minutes apart. The value is a 24-hour "HH:mm" string; the field shows the locale's clock.
Between 8:00 AM and 10:00 PM.
import { Field, TimePicker } from "@vjdesigns/vjdesigns-ui";
export function Basic() {
return (
<Field label="Tip-off" hint="Between 8:00 AM and 10:00 PM." style={{ width: "100%", maxWidth: "16rem" }}>
<TimePicker name="tipoff" min="08:00" max="22:00" step={15} />
</Field>
);
}
Twenty four hour
hourCycle={24} shows a 24-hour clock whatever the locale. clearable adds a clear button.
import { Field, TimePicker } from "@vjdesigns/vjdesigns-ui";
export function TwentyFourHour() {
return (
<Field label="Practice starts" style={{ width: "100%", maxWidth: "16rem" }}>
<TimePicker name="practice" hourCycle={24} defaultValue="18:30" clearable />
</Field>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
Basic
Between 8:00 AM and 10:00 PM.
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// Basic is the "Basic" example above.
<LocaleProvider locale="ar" messages={ar}>
<Basic />
</LocaleProvider>
Usage notes
The value is a 24-hour "HH:mm" string, the same as a native <input type="time">, so it never shifts with time zones. The field shows it in the locale's clock (12- or 24-hour, override with hourCycle). On blur (or Enter), typed text is parsed and normalized, or rejected with an inline, announced error. Inside a Field, label, hint, error, required, disabled, and invalid state are wired to the input.
<Field label="Tip-off">
<TimePicker name="tipoff" min="08:00" max="22:00" step={15} />
</Field>
API reference
TimePicker
New in 1.5.0| Prop | Type | Default |
|---|---|---|
valueSelected time, "HH:mm" (24-hour), or null for none (controlled). | ISOTime | null | — |
defaultValueInitially selected time when uncontrolled. | ISOTime | null | — |
onValueChangeCalled with the new time ("HH:mm") or null when the user picks one from the list, types one and leaves the field, or clears it. Typed text that isn't a valid, allowed time sets the value to null. | (value: ISOTime | null) => void | — |
minEarliest allowed time, "HH:mm". Also where the list starts. | ISOTime | — |
maxLatest allowed time, "HH:mm". Also where the list ends. | ISOTime | — |
stepMinutes between the times in the list. Any minute can still be typed. | number | 30 |
hourCycle12-hour (AM/PM) or 24-hour clock. Defaults to the locale's. | 1224 | — |
localeBCP 47 locale for formatting and parsing. Defaults to the | string | — |
sizeField height and type size. Inherits from a surrounding | "sm""md""lg" | "md" |
nameName of a hidden input that submits the value ("HH:mm") with a form. | string | — |
clearableShows a clear button while there is text. | boolean | false |
placeholderPlaceholder text. Defaults to none: the format is described to screen readers instead. | string | — |
invalidDanger styling and | boolean | — |
requiredRequires a value. Inherits from a surrounding | boolean | — |
disabledDisables the field. Inherits from a surrounding | boolean | — |
readOnlyShows the value without allowing changes. Inherits from a surrounding | boolean | — |
placementPreferred side of the list. Flips when there isn't room. | "top""top-start""top-end""bottom""bottom-start""bottom-end""left""left-start""left-end""right""right-start""right-end" | "bottom-start" |
maxHeightMaximum list height (CSS length, or px as a number). | CSSProperties["maxHeight"] | 16rem |
fullWidthStretches the field to fill its container. | boolean | true |
onInvalidInputCalled when the user leaves the field with text that isn't a valid, allowed time. Use it to set your own | (error: TimeInputError) => void | — |
invalidMessageMessage shown under the field when typed text is rejected. Pass a function to word it per reason, or | ReactNode | ((error: TimeInputError) => ReactNode) | — |
formatDescriptionScreen-reader description of the expected format. | (example: string) => string | (example) => `Example: ${example}` |
showTimesLabelAccessible name of the list button while closed. | string | "Show times" |
hideTimesLabelAccessible name of the list button while open. | string | "Hide times" |
idId for the text input. Inside a | string | — |
aria-labelAccessible name, when there is no visible label ( | string | — |
aria-labelledbyIds of elements that name the field. | string | — |
aria-describedbyIds of elements that describe the field. | string | — |
classNameClass name for the outer root. | string | — |
styleStyle for the outer root. | CSSProperties | — |
refRef to the text input. | Ref<HTMLInputElement> | — |
onBlurCalled when the text input loses focus (after the typed text is committed). | (event: FocusEvent<HTMLInputElement>) => void | — |
See what changed in each version in the Changelog.
Accessibility report
TimePicker targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10037 passed · 0 failed · 28 not applicable · 10 to check by hand
Dark mode
Score 10037 passed · 0 failed · 28 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
| Key | Action |
|---|---|
| Typing | Enter a time in almost any form ("2:30 pm", "1430", "230p"); it filters the list. |
| Arrow Down | Opens the list on the selected time, or moves to the next time. |
| Arrow Up | Previous time. |
| Enter | Picks the highlighted time, or applies the typed one. |
| Escape | Closes the list. |
Built on Combobox: focus stays in the field. Typed text is checked on blur or Enter; an invalid time shows an inline, announced error.
Roles and states
| Element | Role | States and properties |
|---|---|---|
<input> | combobox | aria-expanded, aria-controls → listbox, aria-activedescendant, aria-invalid, aria-describedby → hint and error |
| Times | listbox / option | aria-selected |
| Error | alert | Announced when typed text can't be read as a time |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |