Duration Picker
betaA duration pill that springs apart into hours, minutes and a tick with a gooey melt, clamps and shakes past its ceiling, and merges back on confirm.
- Forms
- 1 file
- 1 npm package
- Accessibility notes
pnpm dlx @dowel-ui/cli add duration-pickernpm packages installed: class-variance-authority.
import { DurationPicker } from "@/components/ui/duration-picker";Default
Editing
Custom Ceiling
Sizes
Controlled
Localised
Disabled
<DurationPicker>
| Prop | Type | Default |
|---|---|---|
defaultEditingStarts in edit mode when uncontrolled. | boolean | false |
defaultValueInitial value when uncontrolled. Default 0 hr 0 min. | DurationValue | { hours: 0, minutes: 0 } |
disabledDims the pill and keeps it shut. | boolean | false |
editingControlled edit mode. | boolean | — |
hoursLabelUnit shown after the hours. Default "hr". | string | "hr" |
labelsAccessible names and announcements, for translation. | Partial<DurationPickerLabels> | — |
maxHoursCeiling for hours; typing past it clamps and shakes. Default 24. | number | 24 |
maxMinutesCeiling for minutes. Default 59. | number | 59 |
minutesLabelUnit shown after the minutes. Default "min". | string | "min" |
onConfirmCalled once with the final value when the tick is pressed or Enter is. | (value: DurationValue) => void | — |
onEditingChange | (editing: boolean) => void | — |
onValueChangeCalled on every keystroke with the clamped value, and when Escape reverts it. | (value: DurationValue) => void | — |
size | "sm" | "md" | "lg" | "md" |
valueControlled value. | DurationValue | — |
Plus every attribute of <div> except defaultValue, onChange, children.
10/10
checks passed
- Tested — passes
- axe assertion — passes
- Keyboard tested — passes
- Storybook examples — passes
- Accessibility documented — passes
- Semantic tokens only — passes
- Motion from tokens — passes
- className merged — passes
- Visible focus — passes
- No fixed widths — passes