Time picker
Pick an hour and minute on a clock dial or by typing, 12- or 24-hour.
import { TimePicker, TimePickerModeToggle, useTimePickerRoom } from '@windmorph/react';Keyboard
| Key | Action | Where |
|---|---|---|
| Tab | Moves through the hour and minute selectors, the AM / PM group and the dial: one stop on the dial, on the chosen number. | |
| Arrow Up or Arrow Down | Steps the hour or minute by one, wrapping at the ends.In the hour and minute selectors | In the hour and minute selectors |
| Arrow Up or Arrow Right | Moves focus to the next number clockwise, wrapping; a 24-hour face runs on from the outer ring to the inner one. The value changes only when a number is chosen.On the dial | On the dial |
| Arrow Down or Arrow Left | Moves focus to the previous number, anticlockwise, wrapping.On the dial | On the dial |
| Enter or Space | Chooses the focused number. Choosing an hour switches the dial to minutes and moves focus to the nearest minute.On the dial | On the dial |
| Arrow Up or Arrow Down or Arrow Left or Arrow Right | Switches between AM and PM, moving focus with the choice.In the AM / PM group | In the AM / PM group |
| Enter or Space | Switches between the dial and the typed input.On TimePickerModeToggle | On TimePickerModeToggle |
- The selectors take typed digits: focusing one selects its text and shows its face on the dial. In input mode a complete hour moves focus on to the minute.
- The time reads hour, minute, then AM / PM left to right in right-to-left layouts too, as Compose does. The AM / PM group follows the page direction (its
dir, not only the locale), so its left and right arrows are mirrored in a right-to-left page. - Pressing or dragging the dial picks the nearest hour (the inner ring within 74px of the centre, on a 24-hour clock) or five minutes; the keys and typing reach any minute.
Screen reader
- Role
- The hour and minute are text inputs (
inputMode="numeric"). AM / PM is aradiogroupof tworadios. The dial is agroupof numbers, each abutton.TimePickerModeToggleis an icon button. - Accessible name
- The inputs are named
labels.hour("Hour") andlabels.minute("Minute"), the AM / PM grouplabels.period("AM or PM"), and the diallabels.dial("Clock"). Each number is named bylabels.dialValuewith the number as the dial shows it ("7 hours of 12", "05 minutes of 60"), so the name holds the visible text. The toggle is namedlabels.inputMode("Toggle input picker") in dial mode andlabels.dialMode("Toggle dial picker") in input mode. - States announced
- The chosen number is pressed (
aria-pressed). AM and PM are checked or not (aria-checked). A typed value out of range marks its inputaria-invalid.
- The ":" between hour and minute, the face fading out, the numbers drawn again under the handle and the input mode's visible labels are hidden from assistive tech (
aria-hidden). - A screen reader activating a dial number (a click with no pointer behind it) chooses it, as Enter does.
Focus
- The dial is one Tab stop with a roving
tabIndex: on the chosen number, or for other minutes the nearest five. - The dial selectors and the focused dial number show M3's focus indicator on keyboard focus only: a 3px
secondaryring, drawn around the number's 48px circle on the dial. AM / PM options draw it inside the option. - In input mode a focused field shows a 2px
primaryborder on aprimary-containerfill, for pointer and keyboard focus alike. - In a
PickerDialog, focus is contained in the dialog and returned to what opened it on close.
Touch target
- Each number on the dial is a 48 × 48px circle. On a 24-hour dial the inner ring's numbers sit about 36px apart, as in Compose, so their circles overlap: a press picks the hour by its angle and its distance from the centre, not by the circle it lands on. The hour and minute selectors are 96 × 80px (114px wide on a 24-hour clock), and the input fields 96 × 72px.
- The AM / PM options are drawn smaller than 48px tall (52 × 40px each in the vertical layout, 52 × 36px in the input mode, 108 × 38px in the horizontal one), but each takes 48px-tall presses: in the vertical layouts AM reaches up and PM down, away from each other, and in the horizontal one each reaches 5px above and below. Nothing in the picker sits in that space.
TimePickerModeToggleis an icon button with a 48 × 48px target. It isn't rendered when the window has no room for the dial, where anautopicker shows only the typed input.
Motion
- Under reduced motion the hand jumps to a new value instead of turning on a spring. A drag moves it directly either way.
- The hour and minute faces still crossfade.
What you need to do
- Give
TimePickerModeTogglethe samelabelsas the picker, so the toggle and the picker use one set of words. - Offer the mode toggle wherever the dial shows, so the time can always be typed.
- Name the
PickerDialogfor what the time is for, with a visibletitleoraria-label.