Clock-Hands Time Picker

Motion Components · Vol. 1

Component

Clock-Hands Time Picker

Variants

The same markup drops into a normal page as a compact CSS clock with draggable hands (no WebGL needed). It re-themes with the colour tokens. Sizes and states below.

Small, 3:15 PM
Default, drag a hand
Disabled

Usage

Paste the markup, include assets/css/tokens.css and assets/css/tailwind.css, then run the script from this page. Listen for chtp:set to get the chosen time.

Accessibility

  • Role and state. The hour and minute hands are real sliders (role="slider" with aria-valuemin, aria-valuemax, aria-valuenow and a spoken aria-valuetext). AM and PM is a radio group, Set time is a button, and a polite live region announces the time you set.
  • Keyboard. Tab to a hand, then arrow keys move it by one minute or one hour, PageUp and PageDown by five minutes or three hours, Home and End jump to the start and end of the dial. Minutes carry into the hour and AM flips to PM at noon. Enter on Set time chimes.
  • Reduced motion. With prefers-reduced-motion the hands jump straight to the time, the gears do not spin, and the chime shows no rings or sparks; the readout and the live region still confirm the result.
  • Touch and pointer. Drags use pointer capture with touch-action off on the dial, the minute snaps to whole minutes, and tapping the dial sets the nearest hand. Every control is at least 40 px.