Skip to content
Thrum

Time input

A time typed in segments: hours, minutes, optional seconds and AM or PM, on the locale's clock or one you set. Use it for a meeting time or an alert window. For a date use the date input, which works the same way.

Install

npx shadcn@latest add @thrum-pro/time-input

This is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.

Props

PropTypeDefaultDescription
valuestring | null–The time as "14:30", or "14:30:15" with seconds, when the parent holds it. Use it with onValueChange.
defaultValuestring | nullDefault nullThe time at first, when the field holds it itself.
onValueChange(value: string | null) => void–Called with the time on a 24-hour clock once every segment is filled, and with null when one is cleared.
secondsbooleanDefault falseShow a seconds segment. The value then carries seconds.
hourCycle12 | 24–12 shows an AM/PM segment and hours 1 to 12, 24 runs the hours from 0 to 23. Defaults to the locale's clock.
stepnumberDefault 1Minutes per arrow press in the minutes segment. Typed minutes are kept as typed.
minstring | null–The earliest valid time, "HH:mm". An earlier one is kept and marks the field invalid.
maxstring | null–The latest valid time, "HH:mm". A later one is kept and marks the field invalid.
localestringDefault "en-US"Sets the segment order, the AM and PM words, the segment names read out and the default clock.
namestring–The field name in a form. A hidden input submits the time as 14:30, or an empty string.
size"sm" | "md" | "lg"Default "md"sm is 28 pixels tall, md 32, lg 40.
disabledbooleanDefault falseDimmed, skipped by Tab, and cannot be changed.
readOnlybooleanDefault falseFocusable and read out, but the keys do not change it.
requiredbooleanDefault falseSets aria-required on every segment. Check for a null value before you submit.
invalidbooleanDefault falseMarks the field invalid for a reason of your own. A time outside min and max marks it on its own.
soundbooleanDefault truePlay a soft tick when stepping a segment with arrow, Page Up/Down or Home/End keys, if the visitor has sound on.
classNamestring–Extra classes for the field, merged last. It fills its container by default.
timeError(time, min, max)"min" | "max" | null–Exported helper: which limit a time breaks, for the message you show beside the field.

Motion and sound

Motion

  • The border colour fades over 150 ms when the field turns invalid.
  • Reduced motion: it changes at once.

Sound

  • A subtle tick when stepping a segment with ↑, ↓, Page Up, Page Down, Home or End. Typing digits is silent.

Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works

Accessibility

  • The field is a group of spin buttons, one per segment, each with its value, its limits and its name in the locale's words (hour, minute).
  • Name the group with aria-labelledby or aria-label, as the example does.
  • The AM/PM segment reads its word (AM, PM), not a number. Typing an hour on a 12-hour clock fills it with AM until you change it.
  • A time outside min and max sets aria-invalid on every segment and turns the border red; point aria-describedby at your message so it is read too.
  • Each segment is editable text, so a phone opens its keyboard. Pasting is ignored.
KeysAction
Tab / Shift TabMove to the next or previous segment, then out of the field.
0 to 9Fill the segment. It moves on once another digit could not fit: after 3 in a 24-hour hour, after two digits in the minutes.
A / PIn the AM/PM segment: set AM or PM, by the first letter of the locale's words.
↑ / ↓Step the segment, round from the last value to the first. Minutes move by step. In the AM/PM segment, switch.
Page Up / Page DownStep the segment by ten steps.
Home / EndThe lowest or highest value of the segment.
← / →Move to the segment before or after.
Backspace / DeleteClear the segment. Backspace on an empty segment moves to the one before.

Source

SourcePro

The source comes with Pro

TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies

Files and dependencies

Adds
components/ui/time-input.tsx
Packages
None
Brings along
Date input

Changelog

  1. 1.0.0 · 2026-12-03First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor