Skip to content
Latestv1.0.63

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.

Basic Usage

Disabled State ​

Use disabled to make the whole control non-interactive.

Disabled State

Clearable ​

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

Clearable

Time Range Selection ​

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

Time Range Selection

Fixed Time Range ​

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

Fixed Time Range

Disabled Time Slots ​

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

Disabled Time Slots

minTime and maxTime Constraints ​

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

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.

Time Format

Custom Time Options ​

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

Custom Time Options

Full Feature Demo ​

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

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.