Skip to content

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

Time picker keyboard
KeyAction
TabMoves 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 DownSteps the hour or minute by one, wrapping at the ends.In the hour and minute selectors
Arrow Up or Arrow RightMoves 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
Arrow Down or Arrow LeftMoves focus to the previous number, anticlockwise, wrapping.On the dial
Enter or SpaceChooses the focused number. Choosing an hour switches the dial to minutes and moves focus to the nearest minute.On the dial
Arrow Up or Arrow Down or Arrow Left or Arrow RightSwitches between AM and PM, moving focus with the choice.In the AM / PM group
Enter or SpaceSwitches between the dial and the typed input.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 a radiogroup of two radios. The dial is a group of numbers, each a button. TimePickerModeToggle is an icon button.
Accessible name
The inputs are named labels.hour ("Hour") and labels.minute ("Minute"), the AM / PM group labels.period ("AM or PM"), and the dial labels.dial ("Clock"). Each number is named by labels.dialValue with 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 named labels.inputMode ("Toggle input picker") in dial mode and labels.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 input aria-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 secondary ring, 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 primary border on a primary-container fill, 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.
  • TimePickerModeToggle is an icon button with a 48 × 48px target. It isn't rendered when the window has no room for the dial, where an auto picker 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 TimePickerModeToggle the same labels as 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 PickerDialog for what the time is for, with a visible title or aria-label.