Time Picker

A time you can type, like 930 or 9:30pm, or pick from a list every 15 minutes, in the same box and states as Input. Built on ui-sdk's Combobox: typing filters the list, Enter takes a time that isn't in it, and the value is "HH:mm".

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { Field, TimePicker } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Props

step
hourCycle
placeholder
disabled
readOnly
required
size

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoUse it for a time of day, like a meeting's start or a court appearance. Pair it with DatePicker when the date is picked too.
DoSet step to the interval appointments book on, like 30 for the half hour. The default is 15 minutes.
DoLet people type the time. "930" and "9:30pm" both work, and Enter takes a time that isn't in the list, so a 9:40 start doesn't have to fit the step.
DoPut it in a Field with a label. Outside a field, name it with aria-label.
Don'tUse it for a duration, like time spent on a matter. It holds a time of day as "HH:mm"; use Input with a suffix for the unit.

Props

PropTypeDefaultDescription
valuestring—The time as "HH:mm", like "09:30".
defaultValuestring—The time it starts with, when uncontrolled.
onChange(value: string) => void—Runs with "HH:mm" when a time is picked, or typed and committed with Enter.
stepnumber15Minutes between the times in the list.
hourCycle12 | 241212 shows "9:30 am", 24 shows "09:30".
sizeTextSize"md"xs 28, sm 32, md 36 (forms, the default), lg 40, as Input.
placeholderstring—Grey hint text while it's empty. Never a replacement for a label.
aria-labelstring—Names the field outside a Field.
idstring—The control's id, for a label's htmlFor or aria-describedby.
namestring—The field's name when a form submits.
disabledboolean—Shows it as unavailable and stops it responding.
readOnlyboolean—Shows the value without letting it change. Still focusable.
requiredboolean—Marks it required: the label gets its asterisk and the form checks it.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

Code

What the playground shows, ready to copy.

import { TimePicker } from "@leap-crm/design-system";

<TimePicker aria-label="Start time" />

Keyboard

The keys it answers to. Tab moves between components, arrows move within them.

KeysWhat they do
TypingFilters the list of times.
Arrow keysMove the highlight while focus stays in the input.
EnterChooses the highlighted time, or takes a typed time between the steps.
EscapeCloses the list and keeps focus in the input.