TimeSelect
Selects from time points at a fixed interval, such as every 30 minutes from 08:30 to 18:30. Use it for appointments or schedules limited to fixed slots. Its dropdown is HuiSelect's, with the same appearance and keyboard interaction. Use TimePicker when arbitrary hours, minutes and seconds are needed.
Import
import { HuiTimeSelect } from '@nscode/handy-ui'
Basic Usage
Bind with v-model. The value is an HH:mm string such as '09:30'. Clearing produces null, and undefined also represents empty. Defaults range from 09:00 to 18:00 in 30-minute intervals, giving 19 time points.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSpace, HuiTimeSelect } from '@nscode/handy-ui'
const time = ref<string | null>(null)
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiTimeSelect v-model="time" style="width: 240px" />
<span>Bound value: {{ time === null ? 'null' : (time ?? 'undefined') }}</span>
</HuiSpace>
</template>
The component defaults to 100% width, filling its parent like HuiSelect. Set style or class for a fixed width. An omitted placeholder uses the active locale's time-selection prompt; an explicit empty string does not fall back. Display token A follows the locale, while a always uses AM / PM. The bound value always uses HH:mm.
Internal and Controlled State
Without modelValue, or with only an update listener, selection is stored internally starting from null. Providing it makes it controlled, with explicit undefined displayed as empty. After the parent accepts, rewrites or rejects a request, the display, selection and native hidden field use the actual value. The display matches normalized time, while the hidden field retains the original string. For example, a parent value of 9:30 displays 09:30 but submits 9:30.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiButton, HuiTimeSelect, HuiSpace } from '@nscode/handy-ui'
const timeBound = ref<string | null | undefined>('09:00')
const timeRedraw = ref(0)
const timeLast = ref('None yet')
const recordTime = (value: string | null | undefined) => {
timeLast.value = value === null ? 'null' : (value ?? 'undefined')
}
</script>
<template>
<HuiSpace class="time-select-q1-demo" direction="vertical" fill :data-parent="timeRedraw">
<HuiSpace wrap>
<HuiButton class="time-redraw" @click="timeRedraw++"
>Parent redraw {{ timeRedraw }}</HuiButton
>
<span>Select 10:00, redraw the parent, then compare display and native form fields.</span>
</HuiSpace>
<HuiSpace class="time-local" wrap>
<span>Model prop omitted</span>
<HuiTimeSelect name="time-local" clearable filterable style="width: 200px" />
</HuiSpace>
<HuiSpace class="time-listener" wrap>
<span>Update listener only</span>
<HuiTimeSelect
@update:model-value="recordTime"
name="time-listener"
clearable
filterable
style="width: 200px"
/>
</HuiSpace>
<HuiSpace class="time-empty" wrap>
<span>Explicit undefined</span>
<HuiTimeSelect
:model-value="undefined"
name="time-empty"
clearable
filterable
style="width: 200px"
/>
</HuiSpace>
<HuiSpace class="time-fixed" wrap>
<span>Fixed 09:00; parent rejects updates</span>
<HuiTimeSelect
model-value="09:00"
name="time-fixed"
clearable
filterable
style="width: 200px"
/>
</HuiSpace>
<HuiSpace class="time-bound" wrap>
<span>Two-way binding</span>
<HuiTimeSelect
v-model="timeBound"
name="time-bound"
clearable
filterable
style="width: 200px"
/>
</HuiSpace>
<span class="time-status"
>Observed request: {{ timeLast }}; bound time:
{{ timeBound === null ? 'null' : (timeBound ?? 'undefined') }}</span
>
</HuiSpace>
</template>
Custom Range and Interval
Start is the first time point, end is the last and step is the interval. All use HH:mm. The interval may contain one hour or more; 01:30 means 1 hour 30 minutes. When end does not fall on an interval, the last point is the one before it. For example, 09:00–10:45 at 30-minute intervals ends with 10:30.
Open each row to inspect the generated time points:
<script setup lang="ts">
import { reactive } from 'vue'
import { HuiSpace, HuiTimeSelect } from '@nscode/handy-ui'
const values = reactive<Record<string, string | null | undefined>>({})
const rows = [
{
key: 'a',
start: '08:30',
end: '18:30',
step: '00:30',
text: '08:30 - 18:30, every 30 minutes'
},
{
key: 'b',
start: '08:00',
end: '12:00',
step: '00:15',
text: '08:00 - 12:00, every 15 minutes'
},
{ key: 'c', start: '00:00', end: '23:00', step: '01:00', text: 'All day, every hour' },
{
key: 'd',
start: '09:00',
end: '17:00',
step: '01:30',
text: '09:00 - 17:00, every 1 hour 30 minutes'
},
{
key: 'e',
start: '09:00',
end: '10:45',
step: '00:30',
text: '09:00 - 10:45, last point 10:30'
}
]
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiSpace v-for="row in rows" :key="row.key" wrap>
<span class="row-label">{{ row.text }}</span>
<HuiTimeSelect
v-model="values[row.key]"
:start="row.start"
:end="row.end"
:step="row.step"
style="width: 180px"
/>
<span class="row-value">{{ values[row.key] ?? 'undefined' }}</span>
</HuiSpace>
</HuiSpace>
</template>
<style scoped>
.row-label {
display: inline-block;
width: 240px;
color: var(--hui-text-color-secondary);
font-size: var(--hui-font-size-sm);
}
.row-value {
color: var(--hui-text-color-secondary);
font-size: var(--hui-font-size-sm);
}
</style>
Linked Start and End Times
Min-time and max-time disable part of the list. Values earlier than or equal to min-time, and later than or equal to max-time, are disabled, including the boundaries themselves. For a start/end pair, bind the start's max-time to the end and the end's min-time to the start. End time must then be later than start time, never equal.
Select a start time, then open the end selector:
<script setup lang="ts">
import { computed, ref } from 'vue'
import { HuiSpace, HuiTimeSelect } from '@nscode/handy-ui'
const startTime = ref<string | null>(null)
const endTime = ref<string | null>(null)
const toMinutes = (time: string) => {
const [hour, minute] = time.split(':').map(Number)
return hour * 60 + minute
}
const duration = computed(() => {
if (!startTime.value || !endTime.value) return 'Choose start and end times'
return `Total: ${toMinutes(endTime.value) - toMinutes(startTime.value)} minutes`
})
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiSpace wrap>
<HuiTimeSelect
v-model="startTime"
start="08:30"
end="18:30"
placeholder="Start time"
:max-time="endTime ?? undefined"
clearable
style="width: 160px"
/>
<span>to</span>
<HuiTimeSelect
v-model="endTime"
start="08:30"
end="18:30"
placeholder="End time"
:min-time="startTime ?? undefined"
clearable
style="width: 160px"
/>
</HuiSpace>
<span>{{ duration }}</span>
</HuiSpace>
</template>
A fixed restriction also works. Below, the left picker permits times after lunch with min-time=12:00, excluding 12:00 itself. The middle permits times before 17:00. The right uses both bounds:
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSpace, HuiTimeSelect } from '@nscode/handy-ui'
const afterLunch = ref<string | null>(null)
const beforeOff = ref<string | null>(null)
const between = ref<string | null>(null)
</script>
<template>
<HuiSpace wrap>
<HuiTimeSelect
v-model="afterLunch"
min-time="12:00"
placeholder="After 12:00"
style="width: 160px"
/>
<HuiTimeSelect
v-model="beforeOff"
max-time="17:00"
placeholder="Before 17:00"
style="width: 160px"
/>
<HuiTimeSelect
v-model="between"
min-time="11:30"
max-time="14:00"
placeholder="Between 11:30 and 14:00"
style="width: 180px"
/>
</HuiSpace>
</template>
Display Format: 12-Hour Clock
Format controls the options and trigger display, defaulting to HH:mm. It affects only display; the bound value remains 24-hour HH:mm.
| Token | Meaning | Example for 13:05 |
|---|---|---|
HH / H | Hour, 24-hour clock | 13 |
hh / h | Hour, 12-hour clock | 01 / 1 |
mm / m | Minute | 05 / 5 |
A | Localized AM / PM | Localized afternoon marker |
a | AM / PM | PM |
[文字] | Literal bracketed text | [点] outputs 点 |
Two-letter tokens pad to two digits. In 12-hour format, midnight displays 12:00 AM and noon displays 12:00 PM.
These selectors share one value and differ only in format:
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSpace, HuiTimeSelect } from '@nscode/handy-ui'
const time = ref('13:30')
const formats = [
{ format: 'HH:mm', text: 'HH:mm (default)' },
{ format: 'H:mm', text: 'H:mm, unpadded hours' },
{ format: 'A hh:mm', text: 'A hh:mm' },
{ format: 'A h:mm', text: 'A h:mm' },
{ format: 'h:mm a', text: 'h:mm a' },
{ format: 'HH[点]mm[分]', text: 'HH[点]mm[分]' }
]
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiSpace v-for="item in formats" :key="item.format" wrap>
<span class="row-label">{{ item.text }}</span>
<HuiTimeSelect
v-model="time"
start="08:00"
end="20:00"
:format="item.format"
style="width: 180px"
/>
</HuiSpace>
<span>Bound value: {{ time }}</span>
</HuiSpace>
</template>
<style scoped>
.row-label {
display: inline-block;
width: 140px;
color: var(--hui-text-color-secondary);
font-size: var(--hui-font-size-sm);
}
</style>
Sizes
Size accepts large, default or small, matching HuiSelect, HuiInput and HuiButton: heights 40 / 32 / 24px, font sizes 16 / 14 / 12px and radii 8 / 6 / 4px. Dropdown options follow the size. When omitted, size follows HuiFormItem, HuiForm and HuiConfigProvider, then default.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiButton, HuiSpace, HuiTimeSelect } from '@nscode/handy-ui'
const time = ref('10:00')
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiSpace wrap>
<span class="row-label">large</span>
<HuiTimeSelect v-model="time" size="large" clearable style="width: 200px" />
<HuiButton size="large">Button</HuiButton>
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">default</span>
<HuiTimeSelect v-model="time" clearable style="width: 200px" />
<HuiButton>Button</HuiButton>
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">small</span>
<HuiTimeSelect v-model="time" size="small" clearable style="width: 200px" />
<HuiButton size="small">Button</HuiButton>
</HuiSpace>
</HuiSpace>
</template>
<style scoped>
.row-label {
display: inline-block;
width: 56px;
color: var(--hui-text-color-secondary);
font-size: var(--hui-font-size-sm);
}
</style>
Disabled
Disabled selectors cannot open or receive Tab focus and do not show a clear button. Use min-time and max-time to disable individual time points.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSpace, HuiTimeSelect } from '@nscode/handy-ui'
const time = ref('10:30')
</script>
<template>
<HuiSpace wrap>
<HuiTimeSelect v-model="time" disabled clearable style="width: 200px" />
<HuiTimeSelect disabled placeholder="No value" style="width: 200px" />
</HuiSpace>
</template>
Clearable
With clearable enabled and a value present, a clear button appears on the right. Clearing sets the value to null and emits update:modelValue, clear and change in order.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSpace, HuiTimeSelect } from '@nscode/handy-ui'
const time = ref<string | null | undefined>('14:00')
const clearCount = ref(0)
</script>
<template>
<HuiSpace wrap>
<HuiTimeSelect v-model="time" clearable style="width: 200px" @clear="clearCount++" />
<span
>Bound value: {{ time === null ? 'null' : (time ?? 'undefined') }}; cleared
{{ clearCount }} times</span
>
</HuiSpace>
</template>
Filtering Input
Enable filterable to type while the dropdown is open and show only time points whose display text contains the query. Enter selects the first match. Filtering uses display text: in the English locale's 12-hour format, PM can match an afternoon time, but 14:30 does not match PM 02:30.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSpace, HuiTimeSelect } from '@nscode/handy-ui'
const time = ref<string | null>(null)
const time12 = ref<string | null>(null)
</script>
<template>
<HuiSpace wrap>
<HuiTimeSelect
v-model="time"
filterable
step="00:15"
placeholder="Try typing 14 or :45"
style="width: 200px"
/>
<HuiTimeSelect
v-model="time12"
filterable
format="A hh:mm"
placeholder="Try typing PM"
style="width: 200px"
/>
</HuiSpace>
</template>
Native Form Submission
Providing name adds a hidden input with the same name. It contains the current bound value, or an empty string when empty, making it available through native form submission or new FormData(form).
<script setup lang="ts">
import { ref } from 'vue'
import { HuiButton, HuiSpace, HuiTimeSelect } from '@nscode/handy-ui'
const time = ref<string | null | undefined>('10:00')
const submitted = ref('')
const onSubmit = (event: Event) => {
const data = new FormData(event.target as HTMLFormElement)
submitted.value = `meeting_time=${String(data.get('meeting_time'))}`
}
</script>
<template>
<form @submit.prevent="onSubmit">
<HuiSpace wrap>
<HuiTimeSelect v-model="time" name="meeting_time" clearable style="width: 200px" />
<HuiButton type="primary" native-type="submit">Submit</HuiButton>
<span>{{ submitted || 'Not submitted yet' }}</span>
</HuiSpace>
</form>
</template>
Within a Form
Inside HuiFormItem, selection and clearing trigger change rules, and closing the dropdown triggers blur rules. Omitted size and disabled props follow the form. Open the start picker and close it without selecting to see the required-field message:
<script setup lang="ts">
import { reactive, ref } from 'vue'
import {
HuiButton,
HuiCheckbox,
HuiForm,
HuiFormItem,
HuiMessage,
HuiSpace,
HuiTimeSelect
} from '@nscode/handy-ui'
import type { FormRule } from '@nscode/handy-ui'
const formRef = ref<InstanceType<typeof HuiForm>>()
const disabled = ref(false)
const model = reactive<{ start?: string | null; end?: string | null }>({
start: undefined,
end: undefined
})
const rules: Record<string, FormRule[]> = {
start: [{ required: true, message: 'Choose a start time', trigger: ['change', 'blur'] }],
end: [{ required: true, message: 'Choose an end time', trigger: ['change', 'blur'] }]
}
const submit = async () => {
const result = await formRef.value?.validate()
if (result?.valid) HuiMessage.success(`Booked ${model.start} - ${model.end}`)
}
</script>
<template>
<HuiForm
ref="formRef"
:model="model"
:rules="rules"
:disabled="disabled"
label-width="80px"
style="max-width: 420px"
>
<HuiFormItem label="Start time" prop="start">
<HuiTimeSelect
v-model="model.start"
start="08:30"
end="18:30"
:max-time="model.end ?? undefined"
clearable
/>
</HuiFormItem>
<HuiFormItem label="End time" prop="end">
<HuiTimeSelect
v-model="model.end"
start="08:30"
end="18:30"
:min-time="model.start ?? undefined"
clearable
/>
</HuiFormItem>
<HuiFormItem>
<HuiSpace>
<HuiButton type="primary" @click="submit">Submit</HuiButton>
<HuiButton @click="formRef?.resetFields()">Reset</HuiButton>
<HuiCheckbox v-model="disabled">Disable form</HuiCheckbox>
</HuiSpace>
</HuiFormItem>
</HuiForm>
</template>
Focus Boundaries and Native Events
Focus and blur forward the same FocusEvent from the internal Select, retaining native events during ordinary focus movement. Entering and leaving the whole group each notify once; moving among the selector, search input and teleported panel does not repeat them. If closing removes the search input without a browser focusout, one blur is synthesized from the final focus state. Moving focus does not submit the model or add validation.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiButton, HuiSelect, HuiSpace, HuiTimeSelect } from '@nscode/handy-ui'
import type { SelectExpose } from '@nscode/handy-ui'
const selectRef = ref<SelectExpose>()
const timeRef = ref<Pick<SelectExpose, 'focus' | 'blur'>>()
const disabled = ref(false)
const selectEvents = ref<string[]>([])
const timeEvents = ref<string[]>([])
const options = [
{ label: 'Option A', value: 'a' },
{ label: 'Option B', value: 'b' }
]
const log = (events: string[], type: string, event: FocusEvent) => {
events.push(`${type}(${event.type})`)
}
</script>
<template>
<HuiSpace class="select-focus-demo" direction="vertical" fill>
<span
>Entry and exit notify once; movement within search and the panel toolbar does not repeat
notifications or change selection.</span
>
<HuiSpace wrap>
<HuiButton class="focus-select" @click="selectRef?.focus()">Focus selector</HuiButton>
<HuiButton class="blur-select" @click="selectRef?.blur()">Blur selector</HuiButton>
<HuiButton class="focus-time" @click="timeRef?.focus()">Focus time selector</HuiButton>
<HuiButton class="toggle-disabled" @click="disabled = !disabled">{{
disabled ? 'Enable' : 'Disable'
}}</HuiButton>
</HuiSpace>
<HuiSelect
ref="selectRef"
class="focus-choice"
multiple
select-all
filterable
:disabled="disabled"
:options="options"
@focus="(event) => log(selectEvents, 'focus', event)"
@blur="(event) => log(selectEvents, 'blur', event)"
/>
<p class="select-focus-events" role="status">
Selector: {{ selectEvents.join(' → ') || 'No focus movement yet' }}
</p>
<HuiTimeSelect
ref="timeRef"
class="focus-time-choice"
filterable
:disabled="disabled"
@focus="(event) => log(timeEvents, 'focus', event)"
@blur="(event) => log(timeEvents, 'blur', event)"
/>
<p class="time-focus-events" role="status">
Time selector: {{ timeEvents.join(' → ') || 'No focus movement yet' }}
</p>
<HuiButton class="focus-outside">External focus target</HuiButton>
</HuiSpace>
</template>
Events
Interact below to see recent events, newest first. Change fires when selecting a time or clearing, including selecting the current time. VisibleChange fires when the dropdown opens or closes. Focus and blur mark entry to and exit from the component; moving between the selector and its filter input does not count.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSpace, HuiTimeSelect } from '@nscode/handy-ui'
const time = ref<string | null>(null)
const logs = ref<string[]>([])
const log = (text: string) => {
logs.value = [text, ...logs.value].slice(0, 6)
}
const onChange = (value: string | null | undefined) => log(`change:${String(value)}`)
const onVisibleChange = (visible: boolean) => log(`visible-change:${visible}`)
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiTimeSelect
v-model="time"
clearable
filterable
style="width: 240px"
@change="onChange"
@clear="log('clear')"
@focus="log('focus')"
@blur="log('blur')"
@visible-change="onVisibleChange"
/>
<div class="event-log">
<div v-for="(item, index) in logs" :key="index">{{ item }}</div>
<div v-if="!logs.length">No events yet</div>
</div>
</HuiSpace>
</template>
<style scoped>
.event-log {
color: var(--hui-text-color-secondary);
font-size: var(--hui-font-size-sm);
line-height: 1.8;
}
</style>
Methods
Call focus and blur through a ref. Focus only focuses the selector without opening the dropdown. When filtering is enabled and the panel is already open, it focuses the search input.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiButton, HuiSpace, HuiTimeSelect } from '@nscode/handy-ui'
import type { TimeSelectInstance } from '@nscode/handy-ui'
const selectRef = ref<TimeSelectInstance>()
const time = ref('09:30')
const focused = ref(false)
// Focus, then blur after 2 seconds
const focusForAWhile = () => {
selectRef.value?.focus()
setTimeout(() => selectRef.value?.blur(), 2000)
}
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiTimeSelect
ref="selectRef"
v-model="time"
style="width: 240px"
@focus="focused = true"
@blur="focused = false"
/>
<HuiSpace wrap>
<HuiButton @click="selectRef?.focus()">Focus (focus)</HuiButton>
<HuiButton @click="focusForAWhile">Focus, then blur after 2 seconds (blur)</HuiButton>
<span>Selector {{ focused ? 'has' : 'does not have' }} focus</span>
</HuiSpace>
</HuiSpace>
</template>
Keyboard Interaction
Use Tab to focus the selector. Once focused:
| Key | Action |
|---|---|
| Enter / Space | Opens a closed dropdown. When open, selects the highlighted time or closes if none is highlighted |
| ↓ / ↑ | Opens a closed dropdown. When open, moves among times, skipping disabled values and wrapping at either end |
| Esc | Closes the dropdown and returns focus to the selector without changing the value |
| Tab | Closes the dropdown and moves to the next element |
- Opening starts navigation from the current selection and scrolls it into view.
- With filtering, Space enters text rather than selecting a time. Enter after typing selects the first match.
- The selector has role=combobox, the dropdown role=listbox and each time point role=option. Disabled values have aria-disabled=true. Screen readers use aria-activedescendant to identify the highlighted time. Inside HuiFormItem, aria-labelledby associates the label; outside a form, provide aria-label, which applies to the selector.
Invalid Configuration
Invalid start, end, step, min-time, max-time or format values produce development console warnings prefixed [HandyUI]. The component handles them as follows rather than throwing:
| Situation | Behavior |
|---|---|
Invalid start, such as '9点' or '24:00' | Uses 09:00 |
| Invalid end time | Uses 18:00 |
| Invalid step format or 00:00 | Uses 00:30 |
| End before start | No time points; opening shows the localized no-data message |
| Invalid min-time or max-time | Ignores that bound without disabling times |
| Format lacks hour/minute tokens HH, H, hh, h, mm or m | Uses HH:mm |
Valid times use H:mm or HH:mm, with hours 0–23 and minutes 00–59. HH:mm:ss is also accepted, ignoring seconds.
Public Clear Method
clear() uses the same request path as the Select clear icon and clears to null. Its request order remains update, clear, then change. Disabled, form-readonly, and unmounted instances do not clear. Controlled values wait for parent acceptance, including rejection or normalization.
TimeSelectExpose is the preferred ref type. TimeSelectInstance remains a deprecated compatibility alias until 1.0.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiButton, HuiSpace, HuiTimeSelect } from '@nscode/handy-ui'
import type { TimeSelectExpose } from '@nscode/handy-ui'
const control = ref<TimeSelectExpose>()
const value = ref<string | null | undefined>('14:00')
const count = ref(0)
</script>
<template>
<HuiSpace direction="vertical" fill>
<HuiButton @click="control?.clear()">Clear time</HuiButton>
<HuiTimeSelect ref="control" v-model="value" clearable @clear="count++" />
<span>Value: {{ JSON.stringify(value) }}; clear requests: {{ count }}</span>
</HuiSpace>
</template>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| modelValue | string | null | - | Internal when omitted or listener-only; controlled when supplied, including undefined/null as empty. Supports v-model. HH:mm, such as 09:30; also accepts 9:30 and 09:30:00 |
| start | string | '09:00' | First time point, HH:mm |
| end | string | '18:00' | Last allowed time, HH:mm. If off interval, uses the final preceding point |
| step | string | '00:30' | Interval in HH:mm; must be greater than 0 |
| minTime | string | - | Disables times earlier than or equal to this HH:mm bound |
| maxTime | string | - | Disables times later than or equal to this HH:mm bound |
| format | string | 'HH:mm' | Display format; does not affect the bound value |
| placeholder | string | Localized time-selection prompt | Placeholder when empty |
| clearable | boolean | false | Whether to show the clear button when nonempty |
| disabled | boolean | false | Disabled state, following the enclosing HuiForm when omitted |
| filterable | boolean | false | Whether to filter times by their displayed text while open |
| size | 'large' | 'default' | 'small' | — | Follows HuiFormItem, HuiForm and HuiConfigProvider, then default |
| name | string | - | Native form field name; renders a hidden input with this name |
| validateEvent | boolean | true | Whether value changes and dropdown closing trigger form-item validation |
Events
| Event | Callback Arguments | Description |
|---|---|---|
| update:modelValue | (value: string | null) | Selection or clearing changes the value |
| change | (value: string | null) | User selection or clearing, including reselecting the current time |
| clear | - | Clear-button or public clear() request. |
| focus | (event: FocusEvent) | Focus enters from outside the component |
| blur | (event: FocusEvent) | Focus leaves the component, excluding movement between selector and search input |
| visibleChange | (visible: boolean) | Dropdown opens or closes |
Slots
No slots.
Methods
Call through a component ref.
| Method | Arguments | Return Value | Description |
|---|---|---|---|
| focus | - | void | Focuses without opening, or focuses search when filtering and already open |
| blur | - | void | Blurs the selector |
| clear | - | void | Same request as the Select clear icon; clears to null. Inactive when disabled, form-readonly, or unmounted; parent rejection preserves the actual value. |
Types
import type {
TimeSelectProps,
TimeSelectEmits,
TimeSelectSize,
TimeSelectExpose,
TimeSelectInstance
} from '@nscode/handy-ui'
type TimeSelectSize = 'large' | 'default' | 'small'
interface TimeSelectExpose {
focus: () => void
blur: () => void
clear: () => void
}
/** @deprecated */
type TimeSelectInstance = TimeSelectExpose