A time picked from a list of steps or typed exactly, shown the locale's way, stored as HH:MM.
$ pnpm dlx shadcn@latest add https://dashral.com/r/time-picker.jsonInstallation
$ pnpm dlx shadcn@latest add https://dashral.com/r/time-picker.jsonAdds the component, the components it builds on, its npm packages and the theme tokens it uses. Using Dashral often? Add the registry to components.json once:
{
"registries": {
"@dashral": "https://dashral.com/r/{name}.json"
}
}Then add components by name:
$ pnpm dlx shadcn@latest add @dashral/time-pickerUsage
import { TimePicker } from "@/components/dashral/time-picker"
<TimePicker label="Start" value={start} onValueChange={setStart} min="08:00" max="18:00" step={15} />Examples
API reference
TimePicker
| Prop | Type | Default |
|---|---|---|
label | ReactNodeShown above, linked to the control. | — |
description | ReactNodeA hint under the control. | — |
error | boolean | ReactNodetrue shows the error style; a message also shows under the control. | — |
labelAction | ReactNodeAt the end of the label's row, e.g. a “Forgot password?” link or the current value. | — |
withAsterisk | booleanMarks the label with an asterisk, e.g. alongside required. | false |
value / defaultValue | stringThe time as "HH:MM", 24-hour ("14:30"), whatever the display. | — |
onValueChange | (time: string | undefined) => voidCalled when a time is picked or typed. | — |
step | numberMinutes between the times in the list. | 30 |
min / max | stringThe earliest and latest times offered. | "00:00" / "23:59" |
hour12 | boolean12-hour (2:30 PM) or 24-hour (14:30) display. | the locale's |
placeholder | stringShown while nothing is picked (translated by default). | "Pick a time" |
locale | stringBCP 47 locale for the display. | — |
disabled / required / id | As on any field. | — |
classNames | { root, label, description, error, trigger, content, option }Classes for each part. | — |
className | stringThe trigger's classes. | — |
Keyboard
| Keys | Action |
|---|---|
| EnterorSpace | Open |
| ↓or↑ | Move through the times |
| Page DownorPage Up | Move six at a time |
| HomeorEnd | The first or last time |
| Enter | Pick the time (or the one typed at the top) |
| Escape | Close |
Accessibility
- With label, description or error, the id, aria-describedby and aria-invalid are wired up for you.
- The times are a listbox of options, the picked one aria-selected; opening it puts the focus on the picked time.
Motion
- Opens with a fade, a scale from 95%, a 2px blur clearing and a 4px slide from its trigger's side, on the spring (--duration-standard); closes faster (--duration-fast, --ease-exit). No blur with reduced motion.