Skip to content

TimeSelect

Use YhTimeSelect to choose from a predefined list of time slots. It fits appointment, scheduling, opening-hours, and other fixed-slot scenarios.

TimePicker vs TimeSelect

  • TimePicker: Select any arbitrary time through a spinner panel.
  • TimeSelect: Select from a predefined list of time options generated from rules or custom data.

Basic Usage

Configure the available options through start, end, and step.

Current value: Not selected

Basic Usage

Disabled State

Use disabled to make the whole control non-interactive.

09:00
Disabled State

Clearable

Set clearable to display a clear icon when a value exists.

10:30

Current value: 10:30

Clearable

Time Range Selection

Link two YhTimeSelect instances together with min-time and max-time.

to

Selected range: -- to --

Time Range Selection

Fixed Time Range

Define a fixed selectable range with start, end, and step.

Hours: 09:00 - 21:00, with 30-minute intervals

Fixed Time Range

Disabled Time Slots

Use disabled-hours to mark specific time ranges as unavailable.

Disabled: 12:00-13:30 and 18:00-19:00

Disabled Time Slots

minTime and maxTime Constraints

Use min-time and max-time to disable options outside the allowed range.

Selectable range: 09:00 - 18:00

minTime and maxTime Constraints

Different Sizes

Use size to switch between large, default, and small.

Different Sizes

Time Format

Set format to control the displayed label text of generated options.

Current value: Not selected

Time Format

Custom Time Options

Use options to provide a fully custom option list. When present, it takes precedence over start, end, and step.

Current value: Not selected

Custom Time Options

Full Feature Demo

This example combines editable filtering, clearing, custom intervals, and end-time inclusion.

Current choice: Not selected

Full Feature Demo

Use in Nuxt

YhTimeSelect can be used directly in Nuxt after registering the YH-UI module. The generated option list and current value render during SSR, while popup positioning, input filtering, and scrolling continue on the client after hydration.

Use in Nuxt

API

Props

NameDescriptionTypeDefault
model-value / v-modelBound valuestringundefined
disabledWhether the component is disabledbooleanfalse
editableWhether the input is editable and filterablebooleantrue
clearableWhether the current value can be clearedbooleantrue
sizeInput size'large' | 'default' | 'small'undefined
placeholderPlaceholder textstring''
nameNative input namestringundefined
effectDropdown visual theme'dark' | 'light''light'
prefix-iconDeclared prefix icon prop. The current template still renders the built-in clock icon and does not consume this propstring | Componentundefined
clear-iconDeclared clear icon prop. The current template still renders the built-in clear icon and does not consume this propstring | Componentundefined
startStart time used to generate optionsstring'09:00'
endEnd time used to generate optionsstring'18:00'
stepTime interval used to generate optionsstring'00:30'
min-timeMinimum selectable timestringundefined
max-timeMaximum selectable timestringundefined
value-on-clearValue emitted when cleared. Falls back to undefined when omittedstringundefined
formatDisplay format for generated optionsstring'HH:mm'
popper-classCustom dropdown class namestringundefined
popper-styleDeclared dropdown style prop. The current implementation does not merge this prop into the dropdown stylesstring | Record<string, string>undefined
teleportedWhether the dropdown is teleported to bodybooleantrue
include-end-timeCompatibility prop for including the end option. The current implementation already includes the exact end time in generated listsbooleanfalse
validate-eventWhether form validation is triggered on change and blurbooleantrue
optionsCustom time option listYhTimeSelectOption[]undefined
disabled-hoursDisabled time rangesstring[][]undefined
theme-overridesComponent-level theme overridesComponentThemeVarsundefined

Events

NameDescriptionParameters
update:modelValueTriggered when the bound value updates(value: string | undefined) => void
changeTriggered when the selected value changes(value: string | undefined) => void
focusTriggered when the input gains focus(event: FocusEvent) => void
blurTriggered when the input loses focus(event: FocusEvent) => void
clearTriggered when the clear icon is clicked() => void
visible-changeTriggered when the dropdown visibility changes(visible: boolean) => void

Slots

NameDescriptionParameters
prefixContent rendered before the input-
emptyContent rendered when no option is available-
optionCustom option content{ option: YhTimeSelectOption }

Expose

NameDescriptionType
focusFocuses the input() => void
blurBlurs the input() => void
inputRefRef to the internal input elementRef<HTMLInputElement | undefined>

Type Exports

NameDescription
YhTimeSelectPropsProps type for YhTimeSelect
YhTimeSelectEmitsEmits type for YhTimeSelect
YhTimeSelectSlotsSlots type for YhTimeSelect
YhTimeSelectExposePublic expose type for YhTimeSelect
YhTimeSelectSizeSize union type
YhTimeSelectOptionTime option item type
YhTimeSelectInstanceComponent instance type

Theme Variables

YhTimeSelect supports themeOverrides. Its stylesheet directly consumes the following component-scoped CSS variables, while border, background, and text color tokens continue to come from the shared theme system.

VariableDescriptionDefault
--yh-time-select-heightControl heightvar(--yh-component-size-default, 32px)
--yh-time-select-font-sizeInput and option font sizevar(--yh-font-size-base, 14px)
--yh-time-select-icon-sizePrefix and suffix icon size14px
--yh-time-select-prefix-marginLeft spacing before the prefix icon12px
--yh-time-select-display-paddingLeft padding for the display label38px

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.