Skip to content
caliper ui pro docs

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.

Pro

Type 45m, 1h 30m or 90; arrow keys step 15 minutes, Shift steps an hour.

Logged 2 h 15 min, 45 min over the estimate.

When to use

  • Estimates, timers, meeting lengths, time logged against a task.
  • Anywhere people think in hours and minutes rather than a clock.

When not to use

  • A time of day; use the time picker.
  • Spans between two dates; use the date range picker.

Installation

terminal
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.

API reference

DurationField

13 props
PropTypeDefaultDescription
value *number | null—Minutes, or null when empty.
onValueChange *(minutes: number | null) => void—
stepnumber15Minutes added or taken by the buttons and arrow keys. Shift or Page keys move an hour.
minnumber0
maxnumber24 * 60
presetsreadonly number[][15, 30, 60, 120]Common lengths offered under the field, in minutes; [] hides them.
placeholderstring"e.g. 1h 30m"
disabledboolean—
idstring—
aria-describedbystring—
aria-invalidtrue—
aria-labelstring—
classNamestring—

formatDuration

0 props

No props of its own; it accepts the native props of its root element.

parseDuration

0 props

No props of its own; it accepts the native props of its root element.

Keyboard

  • No custom key handling; Tab and the native activation keys do the work.

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.

Notes for AI

Give your coding assistant this page as Markdown instead of screenshots: the props, keyboard and examples in one file.

/docs/components/duration-field.md

The index of every part is at /llms.txt.

More in Dates