Skip to content

TimePicker

A time picker for selecting or entering arbitrary points in time. It supports hour/minute/second spinner selection, 12/24-hour formats, time disabling, and other advanced features.

TimePicker vs TimeSelect

  • TimePicker: Free selection of any time point via spinner panels (this component).
  • TimeSelect: Selection from a predefined list of fixed time slots, ideal for appointment scenarios.

Choose the component that best fits your business needs.

Basic Usage

Click the input area to open the time selection panel. Scroll or click to select hours, minutes, and seconds.

Current value: Not selected

Basic Usage

Disabled State

Use the disabled property to disable the entire time picker.

Disabled State

Clearable

Set the clearable property to allow clearing the selected time.

Current value: 09:15:30

Clearable

Different Sizes

Use the size property to change the picker's dimensions. Options: large, default, small.

Different Sizes

12-Hour Format

Set the use12-hours property to enable the 12-hour format (AM/PM).

Current value: Not selected

12-Hour Format

Hide Seconds

Set show-seconds to false to hide the seconds selection column.

Current value: Not selected

Hide Seconds

Arrow Control Mode

Set the arrow-control property to use up/down arrows for time adjustment instead of scrolling lists.

Arrow Control Mode

Step Settings

Use hour-step, minute-step, and second-step properties to set the intervals for time selection.

Hour step: 2, Minute step: 15, Second step: 30

Step Settings

Disabled Time

Use the disabled-time property to restrict selectable times. You can independently disable specific hours, minutes, and seconds.

Disabled: 0-5h, 22-23h, and specific minutes at 12h

Disabled Time

Time Range Selection

Set the is-range property to enable time range selection mode.

to

Current value: Not selected

Time Range Selection

Automatic Range Sorting

By setting order-on-confirm to true, the system will no longer enforce strict disabling constraints (you can pick any time), but will automatically swap the values if the end time is earlier than the start time upon clicking "OK".

to

Current value: 10:00:00 - 08:00:00

Automatic Range Sorting

Full Feature Demo

A demonstration of common TimePicker features: clearable, footer actions, "Now" button, etc.

Full Feature Demo

Usage in Nuxt

The TimePicker component fully supports SSR in Nuxt 3/4. When used in a Nuxt project, it is auto-imported.

Usage in Nuxt

SSR Considerations:

  • ✅ Component structure and styles fully support SSR.
  • ✅ Initial values render correctly on the server.
  • ✅ Panel uses Teleport but is SSR-compatible for the initial load.
  • ⚠️ Spinner scroll positioning becomes active after client-side hydration.
  • ⚠️ DOM-direct operations (like focus) only execute on the client.

SSR Best Practices

TimePicker's core logic is optimized for SSR. All operations that could cause hydration mismatches (like timestamp generation or direct DOM access) are safely deferred to the client side.

API

Props

NameDescriptionTypeDefault
model-value / v-modelBinding valuestring | Date | number | [string, string]
disabledWhether to disable the pickerbooleanfalse
editableWhether the input is editablebooleantrue
clearableWhether the selected value can be clearedbooleantrue
sizeInput size'large' | 'default' | 'small''default'
placeholderPlaceholder textstring'Select time'
start-placeholderPlaceholder for the start time in range modestring'Start time'
end-placeholderPlaceholder for the end time in range modestring'End time'
is-rangeWhether to enable range selectionbooleanfalse
formatTime display formatstring'HH:mm:ss'
value-formatFormat for the bound valuestring'HH:mm:ss'
use12-hoursWhether to use 12-hour formatbooleanfalse
show-secondsWhether to show the seconds columnbooleantrue
hour-stepInterval between selectable hoursnumber1
minute-stepInterval between selectable minutesnumber1
second-stepInterval between selectable secondsnumber1
disabled-timeConfig for disabled timesDisabledTimeConfig
popper-classClass name for the dropdownstring
teleportedWhether to insert the dropdown into bodybooleantrue
range-separatorSeparator for range displaystring'-'
arrow-controlWhether to use arrows for controlbooleanfalse
order-on-confirmWhether to auto-swap range values if end < startbooleanfalse
show-footerWhether to show the bottom footerbooleantrue
show-nowWhether to show the "Now" buttonbooleantrue
confirm-textText for the OK buttonstring'OK'
cancel-textText for the Cancel buttonstring'Cancel'
now-textText for the Now buttonstring'Now'
validate-eventWhether to trigger form validationbooleantrue

DisabledTimeConfig

NameDescriptionType
disabledHoursDisabled hours() => number[]
disabledMinutesDisabled minutes (based on selected hour)(hour: number) => number[]
disabledSecondsDisabled seconds (based on selected hour and minute)(hour: number, minute: number) => number[]

Events

NameDescriptionParameters
changeTriggers when time changes(value: TimeValue | TimeRangeValue) => void
focusTriggers on focus(event: FocusEvent) => void
blurTriggers on blur(event: FocusEvent) => void
clearTriggers when cleared() => void
visible-changeTriggers when the panel shows/hides(visible: boolean) => void
confirmTriggers when the OK button is clicked(value: TimeValue | TimeRangeValue) => void
cancelTriggers when the Cancel button is clicked() => void

Slots

NameDescription
prefixCustom prefix icon
suffixCustom suffix icon
range-separatorCustom range separator content

Expose

NameDescriptionType
focusFocus the picker() => void
blurBlur the picker() => void
openOpen the selection panel() => void
closeClose the selection panel() => void

Theme Variables

All colors support dark mode via the global theme system:

VariableDescriptionDefault
--yh-time-picker-widthPicker width220px
--yh-time-picker-range-widthRange picker width360px
--yh-time-picker-active-colorHighlighted text colorvar(--yh-color-primary)
--yh-time-picker-active-bgHighlighted background colorvar(--yh-color-primary-light-9)
--yh-time-picker-hover-bgHover background colorvar(--yh-fill-color-light)
--yh-time-picker-panel-bgPanel background colorvar(--yh-bg-color-overlay)
--yh-time-picker-panel-shadowPanel shadowvar(--yh-shadow-lg)
--yh-time-picker-text-colorText colorvar(--yh-text-color-primary)
--yh-time-picker-text-secondarySecondary text colorvar(--yh-text-color-secondary)
--yh-time-picker-borderBorder colorvar(--yh-border-color-light)
--yh-time-picker-item-heightOption item height32px
--yh-time-picker-spinner-heightSpinner height192px
--yh-time-picker-border-radiusBorder radiusvar(--yh-border-radius-base)

Released under the MIT License.