Skip to main content

TimePicker

A time picker with three scrolling hour / minute / second columns, controlled / uncontrolled usage, step and hour-range constraints, clearing, and keyboard column navigation.

Basic usage​

Controlled selection

Current value: (not selected)

import { useState } from 'react'
import { LhTimePicker } from '@lh-ui/react'

export default function Demo() {
const [value, setValue] = useState<Date | null>(null)

return (
<LhTimePicker
value={value}
onChange={(val) => setValue(val)}
/>
)
}

TimePicker Props​

PropDescriptionTypeOptionsDefault
valueControlled valueDate | null——
defaultValueUncontrolled default valueDate | null—null
sizeSize'large' | 'medium' | 'small'—Follows ConfigProvider
disabledWhether to disableboolean—false
clearableWhether to be clearableboolean—true
placeholderPlaceholderstring—Derived from format and the locale pack
formatDisplay format (fixed-width tokens HH / mm / ss)string—'HH:mm:ss'
readonlyWhether the inner input is read-onlyboolean—true
arrowControlShow up / down arrow buttons in column headersboolean—false
startStart of the hour columnnumber—0
endEnd of the hour columnnumber—24
stepHourHour stepnumber—1
stepMinuteMinute stepnumber—1
stepSecondSecond stepnumber—1
popperClassExtra class for the panelstring——
sxShorthand layout propsSxProps——
Differences from lh-ui-plus
  • modelValue / update:modelValue are mapped to the value / defaultValue / onChange trio (React naming);
  • Panel positioning uses useLhPopper (geometry + viewport flip), while the Vue version hand-writes fixed positioning without flipping;
  • The panel aria-controls points to the real panel id (plus writes panelId as a class, so the reference dangles);
  • When the panel opens, each column scrolls its active item into the middle of the view (plus only scrolls after wheel / arrow-key stepping).

TimePicker events​

EventDescriptionCallback signatureVue equivalent
onChangeEmitted when a value is confirmed or cleared(value: Date | null) => void@change

Panel interaction​

  • Three list columns: click a time to select it (highlighted with --active); the footer "Now" fills in the current time and "OK" commits and closes;
  • When format has no ss, the panel shows only the hour / minute columns;
  • start / end intersect with 0–23 to bound the hour column; an existing selected hour outside the range is clamped back in;
  • Wheel scrolling over a column steps by step with wrapping (hours wrap within start/end, minutes / seconds wrap over the full range).

Keyboard interaction​

Trigger: Enter / Space / ↓ open the panel and move focus into the hour column, Escape closes it. Inside a column (role="listbox"): ↑ / ↓ step the time by step, ← / → jump between the hour / minute / second columns, Enter / Space confirm the current time, Escape closes and returns focus to the trigger. The trigger is role="combobox", the panel is role="dialog", and each column is a role="listbox" with aria-activedescendant pointing at the active item.

ref​

forwardRef<HTMLDivElement> — the trigger root element.

Styles​

import '@lh-ui/react/style/time-picker'