Skip to content

TimeSelect

Used for selecting or entering a fixed point in time, suitable for appointment, scheduling, and business hour scenarios.

TimePicker vs TimeSelect

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

Basic Usage

The most fundamental time selector. You can customize the start time, end time, and step size.

Current value: Not selected

Basic Usage

Disabled State

Use the disabled property to disable the entire time selector.

09:00
Disabled State

Clearable

Set the clearable property to allow clearing the selected time.

10:30

Current value: 10:30

Clearable

Time Range Selection

Achieve time range linkage with min-time and max-time. The max-time of the start selector binds to the end value, and the min-time of the end selector binds to the start value.

to

Selected range: -- to --

Time Range Selection

Fixed Time Range

Set the time range and intervals using start, end, and step.

Treatment time: 09:00 - 21:00, 30-min slots

Fixed Time Range

Disabled Time Slots

Use the disabled-hours property to disable specific time ranges, such as lunch breaks or meal times.

Disabled: 12:00-13:30 (Lunch), 18:00-19:00 (Dinner)

Disabled Time Slots

minTime and maxTime Constraints

Use min-time and max-time to restrict the selectable range. Options outside this range will be disabled.

Selectable range: 09:00 - 18:00

minTime and maxTime Constraints

Different Sizes

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

Different Sizes

Time Format

Customize the time display format using the format property.

Current value: Not selected

Time Format

Custom Time Options

Use the options property to provide a custom list of time slots, which takes precedence over start/end/step configurations.

Current value: Not selected

Custom Time Options

Full Feature Demo

Showing searchability, clearability, and custom time intervals.

Current selection: Not selected

Full Feature Demo

Usage in Nuxt

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

Usage in Nuxt

SSR Considerations:

  • ✅ Time option lists and initial values are fully supported.
  • ✅ Formatting (format) renders correctly on the server.
  • ✅ Disabled slots and range limits are supported during SSR.
  • ✅ Dropdown lists use Teleport but remain SSR-compatible for the initial load.
  • ⚠️ Scroll positioning and search matching become active after client-side hydration.

SSR Safety

TimeSelect's list of options is pre-generated on the server based on start/end/step parameters, ensuring the dropdown is fully populated on initial load, providing excellent SEO and interaction.

API

Props

NameDescriptionTypeDefault
model-value / v-modelBinding valuestring
disabledWhether to disable the pickerbooleanfalse
editableWhether the input is editable (searchable)booleantrue
clearableWhether the value can be clearedbooleantrue
sizeInput box size'large' | 'default' | 'small''default'
placeholderPlaceholder textstring'Select time'
nameNative name attributestring
effectDropdown theme'dark' | 'light''light'
prefix-iconPrefix iconstring | ComponentClock icon
clear-iconClear iconstring | ComponentClose circle icon
startStart timestring'09:00'
endEnd timestring'18:00'
stepTime intervalstring'00:30'
min-timeMinimum selectable timestring
max-timeMaximum selectable timestring
value-on-clearValue returned on clearstringundefined
formatDisplay formatstring'HH:mm'
popper-classDropdown class namestring
popper-styleDropdown custom stylesstring | object
teleportedWhether to insert the dropdown into bodybooleantrue
include-end-timeWhether to include the end time in the listbooleanfalse
validate-eventWhether to trigger form validationbooleantrue
optionsCustom list of time optionsTimeOption[]
disabled-hoursDisabled time spansstring[][]

TimeOption

NameDescriptionTypeRequired
valueTime valuestring
labelDisplay labelstring
disabledWhether disabledboolean

Events

NameDescriptionParameters
changeTriggers when the value changes(value: string | undefined) => void
focusTriggers on focus(event: FocusEvent) => void
blurTriggers on blur(event: FocusEvent) => void
clearTriggers when cleared() => void
visible-changeTriggers when the dropdown shows/hides(visible: boolean) => void

Slots

NameDescriptionParameters
prefixCustom prefix icon
emptyContent when no data is available
optionCustom content for options{ option: TimeOption }

Expose

NameDescriptionType
focusFocus the component() => void
blurBlur the component() => void
inputRefReference to the native input elementHTMLInputElement | undefined

Theme Variables

VariableDescriptionDefault
--yh-time-select-height-largeLarge size height40px
--yh-time-select-height-defaultDefault size height32px
--yh-time-select-height-smallSmall size height24px
--yh-time-select-border-colorBorder colorvar(--yh-border-color)
--yh-time-select-border-color-hoverHover border colorvar(--yh-border-color-hover)
--yh-time-select-bg-colorBackground colorvar(--yh-fill-color-blank)
--yh-time-select-text-colorText colorvar(--yh-text-color-primary)
--yh-time-select-placeholder-colorPlaceholder text colorvar(--yh-text-color-placeholder)
--yh-time-select-disabled-bg-colorDisabled background colorvar(--yh-fill-color-light)
--yh-time-select-disabled-text-colorDisabled text colorvar(--yh-text-color-disabled)

Use Cases

Appointment System

vue
<template>
  <yh-form :model="form">
    <yh-form-item label="Appointment Date">
      <yh-date-picker v-model="form.date" />
    </yh-form-item>
    <yh-form-item label="Appointment Time">
      <yh-time-select
        v-model="form.time"
        start="09:00"
        end="17:00"
        step="00:30"
        :disabled-hours="[['12:00', '13:00']]"
        placeholder="Select appointment time"
      />
    </yh-form-item>
  </yh-form>
</template>

Business Hours Setup

vue
<template>
  <div style="display: flex; gap: 16px; align-items: center;">
    <yh-time-select
      v-model="openTime"
      :max-time="closeTime"
      start="00:00"
      end="23:59"
      step="00:30"
      placeholder="Opening time"
    />
    <span>-</span>
    <yh-time-select
      v-model="closeTime"
      :min-time="openTime"
      start="00:00"
      end="23:59"
      step="00:30"
      placeholder="Closing time"
    />
  </div>
</template>

Scheduling System

vue
<template>
  <yh-time-select
    v-model="shiftTime"
    :options="[
      { value: '08:00', label: 'Morning Shift (08:00-16:00)' },
      { value: '16:00', label: 'Afternoon Shift (16:00-00:00)' },
      { value: '00:00', label: 'Night Shift (00:00-08:00)' }
    ]"
    placeholder="Select shift"
  />
</template>

Released under the MIT License.