Duration picker
A Calamansi duration field: hours, minutes and a save button in one bar that pulls apart on a real liquid thread when you press the pen.
Tap the pen to edit the duration
- Hr.
- Min.
Installation
npx shadcn@latest add fujiDevv/calamansi-ui/duration-pickerHow to use
import { DurationPicker } from "@/components/ui/duration-picker"export function Demo() {return (<DurationPickerdefaultValue={{ hours: 1, minutes: 30 }}onConfirm={(value) => console.log(value)}/>)}
Props
Options you can pass to customize this component.
valueoptionalDurationValueControlled value, `{ hours, minutes }`. A new outside value is adopted unless the field already shows that number, so typing is never fought.
defaultValueoptionalDurationValueValue on mount when uncontrolled.
onChangeoptional(value: DurationValue) => voidFired on every keystroke with the clamped value.
onConfirmoptional(value: DurationValue) => voidFired when the bar is committed — the tick, or Enter in either field.
editingoptionalbooleanHold the bar open or shut yourself.
defaultEditingoptionalbooleanOpen the bar on mount when uncontrolled.
onEditingChangeoptional(editing: boolean) => voidFired when the pieces split apart or merge back.
maxHoursoptionalnumberCeiling for the hours field, and the verge the input refuses to cross.
maxMinutesoptionalnumberCeiling for the minutes field.
hoursLabeloptionalstringUnit after the hours field, and its accessible name as well.
minutesLabeloptionalstringUnit after the minutes field.
variantoptionalwhitecalamansislatecitrusPalette the save button and its bead are painted in once the seams are open.
sizeoptionalsmmdlgBar height, and with it the corner, the travel and the width a live field grows to.
gapoptionalnumberOverride how far the seams open on each side, in pixels.
radiusoptionalnumberOverride the brand corner radius in pixels. Defaults to the kit's share of the bar — 16 on 40, 20 on 48, 24 on 56.
viscosityoptionalnumberThe SVG blur behind the fuse, in pixels, and so how far a thread reaches: the bridge survives to about 1.234 of this before it severs. Defaults to 0.55 of the gap.
thresholdoptionalnumberThe alpha ramp's slope — how hard the fused edge is, and how much the thread thins before it parts.
gooeyoptionalbooleanRun the fuse at all. Off, the pieces simply slide apart. The filter is skipped under reduced motion either way.
beadoptionalbooleanLeave a bead behind when the thread severs. The drop wears the material of its own seam: the palette at the save button's, the tray's own colour between the two fields.
disabledoptionalbooleanDim the bar and take both the fields and the tick out of play.
classNameoptionalstringExtra classes merged onto the wrapper.
Dependencies
License & Usage
- •Free to use and modify in personal and commercial projects.
- •Attribution to Calamansi UI is appreciated when using a component.
- •Please do not resell the components as your own kit.