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
| Prop | Description | Type | Options | Default |
|---|---|---|---|---|
| value | Controlled value | Date | null | — | — |
| defaultValue | Uncontrolled default value | Date | null | — | null |
| size | Size | 'large' | 'medium' | 'small' | — | Follows ConfigProvider |
| disabled | Whether to disable | boolean | — | false |
| clearable | Whether to be clearable | boolean | — | true |
| placeholder | Placeholder | string | — | Derived from format and the locale pack |
| format | Display format (fixed-width tokens HH / mm / ss) | string | — | 'HH:mm:ss' |
| readonly | Whether the inner input is read-only | boolean | — | true |
| arrowControl | Show up / down arrow buttons in column headers | boolean | — | false |
| start | Start of the hour column | number | — | 0 |
| end | End of the hour column | number | — | 24 |
| stepHour | Hour step | number | — | 1 |
| stepMinute | Minute step | number | — | 1 |
| stepSecond | Second step | number | — | 1 |
| popperClass | Extra class for the panel | string | — | — |
| sx | Shorthand layout props | SxProps | — | — |
Differences from lh-ui-plus
modelValue/update:modelValueare mapped to thevalue/defaultValue/onChangetrio (React naming);- Panel positioning uses
useLhPopper(geometry + viewport flip), while the Vue version hand-writes fixed positioning without flipping; - The panel
aria-controlspoints 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
| Event | Description | Callback signature | Vue equivalent |
|---|---|---|---|
| onChange | Emitted 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/endintersect 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'