Pro
Duration field
A length of time, not a time of day: type it the way you would say it (90, 1h 30m, 1:30), step it with the buttons or arrow keys, or pick a common length.
pnpm dlx shadcn@latest add @caliper/duration-fieldWhen to use
Use it for
- Estimates, timers, meeting lengths, time logged against a task.
- Anywhere people think in hours and minutes rather than a clock.
Skip it when
- A time of day; use the time picker.
- Spans between two dates; use the date range picker.
Decisions
Why it is built this way, so you know what to keep when you change your copy.
Behaviour
- A bare number is minutes
- “90” is how people type a length; reading it as hours would turn a meeting into a quarter of a week. “1.5h” and “1:30” say hours explicitly.
- Say it cannot read it instead of guessing
- Unreadable text stays in the field with a message and an example, so a typo never becomes a wrong value silently.
- Steps land on the grid
- With a 15 minute step, 50 minutes plus one step is 60, not 65, so stepping always reaches round numbers.
Usage
- Store minutes
- The value is a number of minutes or null; format it for display with
formatDuration.
Installation
pnpm dlx shadcn@latest add @caliper/duration-field
Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage
Import it from your copy of the source. The example behind the preview comes with the source. It is built from DurationField, formatDuration and parseDuration.
import { DurationField, formatDuration, parseDuration } from "@/components/ui/duration-field"
The worked example comes with Pro
The 32-line example behind the preview opens here, ready to copy.
- 626 Pro parts, blocks and page templates, all with source
- $149 once, with lifetime updates. No renewal
- A full refund within 14 days if it is not for you
API reference
DurationField
component
formatDuration
component
No props of its own; it accepts the native props of its root element.
parseDuration
component
No props of its own; it accepts the native props of its root element.
Accessibility
It exposes spinbutton, alert and group semantics, with aria-label, aria-hidden, aria-valuenow, aria-valuemin, aria-valuemax and aria-valuetext kept in step with state. Changes that matter are announced through a live region.
No custom key handling; Tab and the native activation keys do the work.
Motion
Transitions use the shared duration and easing tokens. Under prefers-reduced-motion those tokens collapse to instant and travel distances go to zero, so state changes still happen without movement.