Duration Input

Duration Input is a copy-paste React component that stops timesheet logs 1.5 as 1h50 before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/duration-input
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsTimesheet logs 1.5 as 1h50

Was this component page useful?

How do I install Duration Input?

pnpm dlx shadcn@latest add @bollard/duration-input

The files land in your project. They're yours to edit.

How do I use Duration Input in React?

duration-input-usage.tsx
import { DurationInput } from "@/components/ui/duration-input"

<DurationInput label="Time on task (hours)" unit="h" defaultValue="1.50" max={12 * 3600} />

What input mistakes does Duration Input catch?

  • 1.50 meant as 1 h 50 min versus 1.5 hours
  • Ambiguous 1:30 (h:mm or m:ss), asked when limits can't decide
  • Values outside min and max, with the limit as a fix
  • Days converted using hoursPerDay (24 by default)

What props does Duration Input accept?

DurationInput props
PropTypeDefault
label

Visible label.

string"Duration"
value

Controlled text, as typed.

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called with the text and the duration in seconds, or null while it can't be read, is ambiguous or out of range.

(text: string, seconds: number | null) => void—
unit

Unit of a bare number such as "90".

DurationUnit"m"
colon

How "1:30" is read. "auto" uses min/max and asks when both readings fit.

ColonMode"auto"
min

Smallest allowed duration, in seconds.

number—
max

Largest allowed duration, in seconds.

number—
hoursPerDay

Hours in a "day", e.g. 8 for work-day estimates.

number24
hint

Helper text shown while the field is empty.

string—
messages

Override any of the default messages.

Partial<typeof DURATION_MESSAGES>—

* required. Also accepts the native props of <input> (className, aria-*, data-*…), passed through to it.

How is Duration Input accessible?

  • Labelled input with the result read back in words
  • Each interpretation is a button with visible text

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

  • Parses English unit words and abbreviations only
  • Days are 24 hours by default; set hoursPerDay (e.g. 8) for working days

What expensive mistakes does Duration Input stop?

Timesheet logs 1.5 as 1h50

Also known as

duration · timesheet · hours · time tracking · estimate · jira · minutes · 1h30m

What dependencies does Duration Input require?

Duration Input facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameDuration Input
Registry identifier@bollard/duration-input
Install commandnpx shadcn@latest add @bollard/duration-input
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Duration Input

How does Duration Input handle date and time accuracy?

Duration Input catches timesheet logs 1.5 as 1h50. Validates calendar constraints: 1.50 meant as 1 h 50 min versus 1.5 hours, Ambiguous 1:30 (h:mm or m:ss), asked when limits can't decide, Values outside min and max, with the limit as a fix, Days converted using hoursPerDay (24 by default). Limitation: match duration-input with server timezone.

How do I install duration-input with shadcn?

Run `npx shadcn@latest add @bollard/duration-input`. Sources added: registry/default/duration-input/duration-input.tsx, registry/default/duration-input/duration.ts. Package requirements: lucide-react.

What props customize Duration Input?

Duration Input accepts `label`, `value`, `defaultValue`, `onValueChange`, `unit`. Configures duration, timesheet, hours behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of duration-input?

Parses English unit words and abbreviations only. Days are 24 hours by default; set hoursPerDay (e.g. 8) for working days Server requirement: backend verification for duration-input.

How does Duration Input meet accessibility guidelines?

Labelled input with the result read back in words. Each interpretation is a button with visible text. Minimizes errors: 1.5 hours vs 1:30, duration format parse.

Which components pair with Duration Input?