Use it for a time of day in shift planners, booking forms, report schedules and working-hours
settings: typed in the field, or picked on a dial. shadcn has no time picker and the native
<input type="time"> looks and behaves differently in every browser. It has three presets:
field (a typed field whose dial opens in a popover), inline (the dial in a card, for schedules
and settings that keep it on screen) and range (From and To fields sharing one popover with two
dials and the duration). For a date, use the Date Picker; for a
duration in minutes, a Number Input is quicker.
The time picker follows the MotionKit motion grammar in three beats. Pressing the field
charges it: it sinks, then the dial morphs out of it as one surface. The hand is a pill from
the centre to a ball on the rim (the action): dragging it, the ball springs from mark to mark,
never snapping, and lands on each one by squashing against it from the side it arrives (the
settle). Choosing the hour, the ball travels inward to the minutes ring while the pill
retracts and the marks crossfade; the field's digits roll as the hand moves. Enter contracts the
dial back into the field.
import { useState } from "react"import { TimePicker, type TimeValue } from "@/components/ui/time-picker"export function SendAt() { const [time, setTime] = useState<TimeValue | null>({ hours: 8, minutes: 0 }) return ( <div className="grid gap-1.5"> <label htmlFor="send-at" className="text-sm font-medium"> Send report at </label> <TimePicker id="send-at" name="sendAt" value={time} onValueChange={setTime} /> </div> )}
Values are plain objects, { hours: 0-23, minutes: 0-59 }, or null when cleared. The field
accepts HH:mm, HHmm and h:mm a (9:30 pm); text that does not read shows an error under the
field when you press Enter or leave it. hourCycle defaults to the locale's (en-GB: 24 h).
With name, the picker submits HH:mm in a hidden input (name[from] and name[to] for a
range). In the popover the time is pending until Done, Enter or a click outside; Escape cancels it.
Every hour and every minute can be picked (15:27 included). Limit the choice only when you need
to: step (minutes between stops, e.g. 15), min and max. Hours and minutes outside them
stay on the dial in a muted color.
A range, with the duration rolling under the two dials:
import { TimePicker, type TimeRange } from "@/components/ui/time-picker"const [hours, setHours] = useState<TimeRange>({ from: null, to: null })<TimePicker preset="range" aria-label="Opening hours" value={hours} onValueChange={setHours} />
TimeDial is exported alone for your own layout. Set the character for the whole app with
MotionKitProvider, or per picker with temperament:
Customers see these hours on the booking page. Closing after midnight counts as overnight.
time-picker · , lively
time-picker-range-demo.tsx
preset="field" in a scheduled-exports form: quick picks under the dial (Start of day, Noon, End
of day), a 12 h field with min and max (marks outside the range are struck through and the
hand will not go there), and a disabled field.
preset="range" for a store's opening hours: two dials side by side (one below the other on
narrow screens) and the duration, "9 h 30 min", rolling as either hand moves. An end before the
start runs overnight.
The field is a text input with role="combobox", aria-haspopup="dialog" and aria-expanded.
Give it a name with a <label htmlFor> pointing at its id, or aria-label (the range preset
appends ", from" and ", to").
The popover is role="dialog" labelled "Choose time" (or "Choose time range"). The hand's ball
is a role="slider" named "Hours" or "Minutes", with aria-valuenow and aria-valuetext ("9
hours", "30 minutes", "9 AM"). The readout's Hours and Minutes segments are toggle buttons that
pick the ring; AM and PM are toggle buttons in a "Period" group.
A polite live region announces the committed time ("09:30 selected"). A typed-time error is
announced and linked to the field with aria-describedby.
The marks, ticks, pill and pivot are decorative (aria-hidden). Marks use foreground on
muted, the ball's digits primary-foreground on primary: AA in light and dark. Marks out of
min/max are struck through as well as muted.
Focus shows a 3px ring in the theme's ring color on the field, the ball, the segments, quick
picks and Done. Escape and commit return focus to the field.
With reduced motion (the OS setting, or MotionKitProvider reducedMotion="always") there is no
field sink, morph, kick or roll. The dial crossfades in place, the hand glides to its mark in a
short fade, the hours and minutes rings crossfade and the digits crossfade. The inline dial's
draw-in is skipped: the hand is already on its mark. The rest look (rimmed face, pill hand, ball
tip) is complete on its own.
Only transform and opacity animate (field sink, morph, hand rotation and length, ball
position and squash, ring crossfade, digit roll). The dial mounts only when the popover opens.
Nothing loops: every movement is caused by a press, drag, key or typed time; the inline draw-in
runs once, when the dial first comes into view.
Size: the component and its MotionKit helpers (morph, ball, roll, beats) count toward the 15 kB
Pro budget. Third-party dependencies come on top: @radix-ui/react-popover about 23 kB gzip
(shared with shadcn's Popover) and motion about 47 kB (shared by every MotionKit component,
installed once).
SSR-safe: "Now" style presets and the opening time are read on the client, in event handlers.
Technical sheet
Motion
calm
260 ms · bounce 0
lively
400 ms · bounce 0.3
playful
540 ms · bounce 0.45
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Size
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom, @radix-ui/react-popover, motion.
Dependencies
@radix-ui/react-popover · peer
motion · peer
Triggers
click, drag, press, typing, keyboard focus
Reduced motion
No sink, morph, kick or roll: the dial crossfades in place, the hand glides in a short fade, the rings and digits crossfade.
Keyboard
ArrowDown / Alt + ArrowDown
From the field: opens the dial
ArrowRight / ArrowUp
On the hand: next hour, or next minute (or step)
ArrowLeft / ArrowDown
On the hand: previous hour, or previous minute (or step)
Shift + Arrow keys
On the hand: five marks at a time
Home / End
On the hand: first / last hour or minute
Enter
Commits the time and the dial contracts back into the field (inline: hours to minutes)
Escape
Cancels the change, closes the dial and returns focus to the field
Tab
Moves between the hours and minutes segments, AM/PM, the hand, quick picks and Done
Browsers
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)