TimePicker
Selects a time of day: hours, minutes and seconds. Open the panel from the input, choose a time and confirm to apply it, or type directly into the input.
Import
import { HuiTimePicker } from '@nscode/handy-ui'
Native Attributes and Label Associations
class and style stay on the visible wrapper. id, name, autocomplete, tabindex, ARIA and other native attributes apply only to the input. An explicit ID stays in sync with the FormItem label. User description IDs and form description/error IDs are merged dynamically and deduplicated. Reserved state markers data-hui-field, data-invalid, data-disabled, data-open and data-filled apply only to the element drawing the border. An external value attribute does not override the actual model.
Omitted autocomplete remains off. Explicit values, including an empty string, are preserved as native input attributes.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiButton, HuiSpace, HuiTimePicker } from '@nscode/handy-ui'
const version = ref(1)
const value = ref<string | null>('09:30:00')
</script>
<template>
<HuiSpace direction="vertical" fill>
<HuiButton @click="version++">Change field ID</HuiButton>
<label :for="`native-timepicker-${version}`">Field name</label>
<HuiTimePicker
:id="`native-timepicker-${version}`"
v-model="value"
name="native-timepicker"
aria-describedby="native-timepicker-help"
autocomplete="on"
style="width: 280px; max-width: 100%"
/>
<span id="native-timepicker-help"
>The label and description always reference the actual input.</span
>
</HuiSpace>
</template>
Basic Usage
Bind with v-model. The default value is a string formatted as HH:mm:ss. Either undefined or null can represent no value. Clearing produces null, matching DatePicker.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiTimePicker } from '@nscode/handy-ui'
const time = ref<string | null>()
</script>
<template>
<HuiTimePicker v-model="time" placeholder="Choose a time" style="width: 240px" />
<p style="margin-top: 12px">Bound value: {{ String(time) }}</p>
</template>
The component defaults to 100% width; use 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. Panel buttons, list names and display token A follow the locale; a always uses AM / PM. Switching locale does not change the bound value. Token A within valueFormat retains the existing Simplified Chinese AM/PM representation.
Display Format
format determines the input display and which columns appear in the panel. Units absent from the format have no corresponding column.
| Token | Meaning | Description |
|---|---|---|
HH / H | Hour, 24-hour clock | HH pads to two digits; H does not |
hh / h | Hour, 12-hour clock | Uses 12-hour time only when A or a is present; see 12-Hour Clock |
mm / m | Minute | Same padding rule |
ss / s | Second | Same padding rule |
A | Localized AM / PM | For example, the localized afternoon marker |
a | AM / PM | For example, PM |
Other characters are displayed literally. Wrap text containing H, h, m, s, A or a in brackets, such as HH:mm [hours].
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSpace, HuiTimePicker } from '@nscode/handy-ui'
const time = ref('08:30:00')
</script>
<template>
<HuiSpace direction="vertical" fill>
<!-- Select only hours and minutes; display 08:30 -->
<HuiTimePicker v-model="time" format="HH:mm" />
<!-- Display 08时30分00秒 using the literal Chinese units -->
<HuiTimePicker v-model="time" format="HH时mm分ss秒" />
</HuiSpace>
</template>
These pickers share one value but use different formats. Open the panels to compare the columns. Each sets value-format="HH:mm:ss" so all emit the same value format; the next section explains why.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSpace, HuiTimePicker } from '@nscode/handy-ui'
const time = ref('08:05:09')
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiSpace wrap>
<span class="row-label">HH:mm:ss (default)</span>
<HuiTimePicker v-model="time" value-format="HH:mm:ss" style="width: 200px" />
<span class="row-value">Three columns: hours, minutes and seconds</span>
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">HH:mm</span>
<HuiTimePicker v-model="time" format="HH:mm" value-format="HH:mm:ss" style="width: 200px" />
<span class="row-value">Two columns: hours and minutes</span>
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">mm:ss</span>
<HuiTimePicker v-model="time" format="mm:ss" value-format="HH:mm:ss" style="width: 200px" />
<span class="row-value">Two columns: minutes and seconds, suitable for durations</span>
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">HH</span>
<HuiTimePicker v-model="time" format="HH[ 点]" value-format="HH:mm:ss" style="width: 200px" />
<span class="row-value">One hour column, using format HH[ 点]</span>
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">H:m:s</span>
<HuiTimePicker v-model="time" format="H:m:s" value-format="HH:mm:ss" style="width: 200px" />
<span class="row-value">No zero padding; displays 8:5:9</span>
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">HH时mm分ss秒</span>
<HuiTimePicker
v-model="time"
format="HH时mm分ss秒"
value-format="HH:mm:ss"
style="width: 200px"
/>
<span class="row-value">Literal Chinese units</span>
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">HH [h] mm [min]</span>
<HuiTimePicker
v-model="time"
format="HH [h] mm [min]"
value-format="HH:mm:ss"
style="width: 200px"
/>
<span class="row-value">Wrap text containing h or m in brackets</span>
</HuiSpace>
</HuiSpace>
<p style="margin-top: 12px">Bound value: {{ time }}</p>
</template>
<style scoped>
.row-label {
display: inline-block;
width: 120px;
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>
12-Hour Clock
When a format contains A for localized AM/PM or a for AM/PM, hh and h display 12-hour time. The hour column is 12, 01–11, and an AM/PM column is added. Midnight displays as 12:00 AM and noon as 12:00 PM, following the same rules as TimeSelect.
The bound value is unaffected. Without valueFormat, it remains a 24-hour HH:mm value: a display of 02:30 PM binds 14:30. Manual input accepts both the Chinese morning/afternoon markers and AM/PM, with AM/PM case-insensitive.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSpace, HuiTimePicker } from '@nscode/handy-ui'
const time = ref<string | null>('14:30')
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiSpace>
<span class="row-label">A hh:mm</span>
<HuiTimePicker v-model="time" format="A hh:mm" style="width: 200px" />
</HuiSpace>
<HuiSpace>
<span class="row-label">hh:mm a</span>
<HuiTimePicker v-model="time" format="hh:mm a" style="width: 200px" />
</HuiSpace>
<span class="row-value">Bound value: {{ String(time) }}</span>
</HuiSpace>
</template>
<style scoped>
.row-label {
display: inline-block;
width: 80px;
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>
Using hh or h without A or a retains the legacy 24-hour interpretation and produces a development warning. Use HH or H for 24-hour time.
Bound Value Format
valueFormat controls the value received by v-model independently of the display format.
valueFormat | Bound Value |
|---|---|
| Omitted option | A string joining the columns present in format with colons. format="HH:mm:ss" produces 12:30:00; format="HH:mm" or format="HH时mm分" produces 12:30. If the initial bound value is a Date, emitted values are also Dates |
| Format string, such as HH:mm:ss or HH-mm | A string in that format, using the same unit tokens as format |
Date | A Date object |
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSpace, HuiTimePicker } from '@nscode/handy-ui'
// Display hours and minutes but include seconds in the submitted value
const time = ref('08:30:00')
// Bind a Date
const date = ref<Date>()
</script>
<template>
<HuiSpace direction="vertical" fill>
<HuiTimePicker v-model="time" format="HH:mm" value-format="HH:mm:ss" />
<HuiTimePicker v-model="date" value-format="Date" />
</HuiSpace>
</template>
For a Date value, only hours, minutes and seconds change; the calendar date is retained. Without an existing value, today's date is used.
Select a time in each row to inspect its bound value on the right:
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSpace, HuiTimePicker } from '@nscode/handy-ui'
const plain = ref('08:30:00')
const minutes = ref('08:30')
const withSeconds = ref('08:30:00')
const custom = ref('08-30')
const asDate = ref<Date>()
const initialDate = ref<Date>(new Date(2024, 0, 15, 8, 30, 0))
const show = (value: Date | string | null | undefined) => {
if (value instanceof Date) return `Date:${value.toLocaleString()}`
return value == null ? String(value) : `'${value}'`
}
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiSpace wrap>
<span class="row-label">Omitted</span>
<HuiTimePicker v-model="plain" style="width: 200px" />
<span class="row-value">{{ show(plain) }}</span>
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">Omitted, format="HH:mm"</span>
<HuiTimePicker v-model="minutes" format="HH:mm" style="width: 200px" />
<span class="row-value">{{ show(minutes) }}</span>
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">HH:mm:ss,format="HH:mm"</span>
<HuiTimePicker
v-model="withSeconds"
format="HH:mm"
value-format="HH:mm:ss"
style="width: 200px"
/>
<span class="row-value">{{ show(withSeconds) }}</span>
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">HH-mm</span>
<HuiTimePicker v-model="custom" format="HH:mm" value-format="HH-mm" style="width: 200px" />
<span class="row-value">{{ show(custom) }}</span>
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">Date</span>
<HuiTimePicker v-model="asDate" value-format="Date" style="width: 200px" />
<span class="row-value">{{ show(asDate) }}</span>
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">Omitted, initial value is a Date</span>
<HuiTimePicker v-model="initialDate" style="width: 200px" />
<span class="row-value">{{ show(initialDate) }}</span>
</HuiSpace>
</HuiSpace>
</template>
<style scoped>
.row-label {
display: inline-block;
width: 168px;
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>
After changing the time in the last row, the date remains January 15, 2024.
Clearable
With clearable enabled and a value present, a clear button appears on the right. Clearing sets the bound value to null, so JSON.stringify does not omit the field, and emits clear.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiTimePicker } from '@nscode/handy-ui'
const time = ref<string | null>('08:30:00')
const clearCount = ref(0)
</script>
<template>
<HuiTimePicker v-model="time" clearable style="width: 240px" @clear="clearCount++" />
<p style="margin-top: 12px">Bound value: {{ String(time) }}; cleared {{ clearCount }} times</p>
</template>
Manual Input
Direct input is enabled by default:
- A complete value matching format, such as 12:30:45, takes effect immediately.
- Unpadded input, such as 9:5:7, is normalized and applied on blur or Enter.
- Non-time content and out-of-range times, such as 25:00:00, do not apply. Blur restores the previous value.
Set editable to false to prevent typing and allow panel selection only.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSpace, HuiTimePicker } from '@nscode/handy-ui'
const time = ref('08:30:00')
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiSpace wrap>
<span class="row-label">Editable (default)</span>
<HuiTimePicker v-model="time" style="width: 200px" />
<span class="row-value">Try typing 9:5:7 and pressing Enter</span>
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">editable=false</span>
<HuiTimePicker v-model="time" :editable="false" style="width: 200px" />
<span class="row-value">Panel selection only</span>
</HuiSpace>
</HuiSpace>
</template>
<style scoped>
.row-label {
display: inline-block;
width: 120px;
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>
Disabled and Read Only
Both disabled and readonly prevent panel opening and typing and hide the clear button. Disabled also mutes the control and prevents input focus; readonly keeps its normal appearance.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSpace, HuiTimePicker } from '@nscode/handy-ui'
const time = ref('08:30:00')
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiSpace wrap>
<span class="row-label">disabled</span>
<HuiTimePicker v-model="time" disabled clearable style="width: 200px" />
<HuiTimePicker disabled placeholder="No value" style="width: 200px" />
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">readonly</span>
<HuiTimePicker v-model="time" readonly clearable style="width: 200px" />
<HuiTimePicker readonly placeholder="No value" style="width: 200px" />
</HuiSpace>
</HuiSpace>
</template>
<style scoped>
.row-label {
display: inline-block;
width: 64px;
color: var(--hui-text-color-secondary);
font-size: var(--hui-font-size-sm);
}
</style>
Sizes
Size accepts large, default or small, matching Input, Select and Button: heights 40 / 32 / 24px, font sizes 16 / 14 / 12px, radii 8 / 6 / 4px, and clock/clear icons 18 / 16 / 14px. Panel dimensions do not change with size. When omitted, size follows the enclosing HuiForm / HuiFormItem, then HuiConfigProvider, and finally default.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiButton, HuiSpace, HuiTimePicker } from '@nscode/handy-ui'
const time = ref('08:30:00')
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiSpace wrap>
<span class="row-label">large</span>
<HuiTimePicker v-model="time" size="large" clearable style="width: 200px" />
<HuiButton size="large">Button</HuiButton>
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">default</span>
<HuiTimePicker v-model="time" clearable style="width: 200px" />
<HuiButton>Button</HuiButton>
</HuiSpace>
<HuiSpace wrap>
<span class="row-label">small</span>
<HuiTimePicker 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>
Events
Interact with the picker below to see recent events, newest first. Confirm emits change even when the selected time is unchanged.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiTimePicker } from '@nscode/handy-ui'
const time = ref<string>()
const logs = ref<string[]>([])
const log = (text: string) => {
logs.value = [text, ...logs.value].slice(0, 6)
}
const onChange = (value: Date | string | null) => log(`change:${String(value)}`)
</script>
<template>
<HuiTimePicker
v-model="time"
clearable
style="width: 240px"
@change="onChange"
@clear="log('clear')"
@focus="log('focus')"
@blur="log('blur')"
/>
<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>
</template>
<style scoped>
.event-log {
margin-top: 12px;
color: var(--hui-text-color-secondary);
font-size: var(--hui-font-size-sm);
line-height: 1.8;
}
</style>
Methods
Call focus, blur and clear through a ref. Focus targets the actual trigger without opening the panel. When focus is inside the panel, focus returns it to the trigger and blur moves it out of the whole control. Clear shares the clear icon's request entry point.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiButton, HuiSpace, HuiTimePicker } from '@nscode/handy-ui'
import type { TimePickerExpose } from '@nscode/handy-ui'
const pickerRef = ref<TimePickerExpose>()
const time = ref('08:30:00')
const focused = ref(false)
// Focus, then blur after 2 seconds
const focusForAWhile = () => {
pickerRef.value?.focus()
setTimeout(() => pickerRef.value?.blur(), 2000)
}
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiTimePicker
ref="pickerRef"
v-model="time"
style="width: 240px"
@focus="focused = true"
@blur="focused = false"
/>
<HuiSpace wrap>
<HuiButton @click="pickerRef?.focus()">Focus (focus)</HuiButton>
<HuiButton @click="focusForAWhile">Focus, then blur after 2 seconds (blur)</HuiButton>
<span>Input {{ focused ? 'has' : 'does not have' }} focus</span>
</HuiSpace>
</HuiSpace>
</template>
Keyboard Interaction
When the input is focused:
| Key | Action |
|---|---|
Enter | Opens a closed panel; otherwise acts as Confirm |
↓ | Opens a closed panel; otherwise focuses its first column |
Esc | Closes the panel without changing the value |
Tab | Enters the first column without closing an open panel; otherwise moves out normally |
Shift+Tab | Moves backward out of the input and closes the panel |
When focus is in the panel:
| Key | Action |
|---|---|
↑ ↓ | Selects the previous or next item in the column, wrapping at either end, such as hour 23 to 0 |
Home End | Selects the first or last item in the column |
Enter | Confirms from a list; activates Cancel or Confirm when focused on that button |
Esc | Closes without changing the value and returns focus to the input |
Tab | Visits the hour, minute and second columns, then Cancel and Confirm. Tab from Confirm closes without changing the value and returns to the input |
Shift+Tab | Moves backward. From the first column, returns to the input without closing the panel |
- Arrow keys change only the panel draft. Enter or Confirm applies it, just like mouse selection.
- Each column is a list with role=listbox. Focus stays on the list, and aria-activedescendant identifies the selected item to screen readers.
- The input has
role="combobox",aria-haspopup="dialog"andaria-expanded. The panel hasrole="dialog"and takes its name from the placeholder; once it has been opened, the input points to it witharia-controls. - Moving keyboard focus from the input into the panel applies a partially typed time such as 8:5, but stays inside the control and emits no component blur or form blur validation. These run only when focus leaves both trigger and panel. Closing back to the trigger does not run blur validation either.
Internal and Controlled State
Without modelValue, or with only an update listener, the component stores its time internally starting from null. Providing it makes it controlled; undefined/null are empty. Complete typing, normalization on blur and panel confirmation all issue candidate requests. Display is restored from the actual model after the parent accepts, rewrites or rejects them. Unconfirmed panel choices and unfinished input remain drafts. New input in the same batch is not overwritten by an earlier submission's synchronization. A parent redraw with a new Date representing the same instant does not discard the panel draft.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiButton, HuiTimePicker, HuiSpace } from '@nscode/handy-ui'
const timeStateBound = ref<Date | string | null>('09:30:00')
const timeStateRedraw = ref(0)
const timeStateLast = ref('None yet')
const recordTimeState = (value: Date | string | null) => {
timeStateLast.value = value instanceof Date ? value.toISOString() : JSON.stringify(value)
}
</script>
<template>
<HuiSpace class="time-picker-q1-demo" direction="vertical" fill :data-parent="timeStateRedraw">
<HuiButton class="time-state-redraw" @click="timeStateRedraw++"
>Parent redraw {{ timeStateRedraw }}</HuiButton
>
<span
>Type 11:45:30 or select and confirm in the panel; fixed and explicit empty values follow the
parent's actual time.</span
>
<HuiSpace class="time-state-local" wrap>
<span>Model prop omitted</span>
<HuiTimePicker clearable style="width: 200px" />
</HuiSpace>
<HuiSpace class="time-state-listener" wrap>
<span>Update listener only</span>
<HuiTimePicker @update:model-value="recordTimeState" clearable style="width: 200px" />
</HuiSpace>
<HuiSpace class="time-state-empty" wrap>
<span>Explicit undefined</span>
<HuiTimePicker :model-value="undefined" clearable style="width: 200px" />
</HuiSpace>
<HuiSpace class="time-state-fixed" wrap>
<span>Fixed 09:30; parent rejects updates</span>
<HuiTimePicker model-value="09:30:00" clearable style="width: 200px" />
</HuiSpace>
<HuiSpace class="time-state-bound" wrap>
<span>Two-way binding</span>
<HuiTimePicker v-model="timeStateBound" clearable style="width: 200px" />
</HuiSpace>
<span class="time-state-status"
>Observed request: {{ timeStateLast }}; bound time: {{ timeStateBound }}</span
>
</HuiSpace>
</template>
Public Clear Method and the Actual Parent Value
Clear shares the icon's request entry point, emitting update:modelValue(null), clear and change(null) in order. A rejection or normalized parent response displays the actual parent value. Clearable controls only the icon; the method works without it. Calls have no effect while disabled, read only or unmounted. Synchronous callback reentry does not emit a duplicate event group. New input or unmounting initiated from a callback stops the remaining old operation.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiButton, HuiSpace, HuiTimePicker } from '@nscode/handy-ui'
import type { TimePickerExpose } from '@nscode/handy-ui'
const boundRef = ref<TimePickerExpose>()
const fixedRef = ref<TimePickerExpose>()
const bound = ref<Date | string | null>('09:30:00')
const accepted = ref<string[]>([])
const rejected = ref<string[]>([])
const record = (target: string[], name: string, value?: Date | string | null) => {
target.push(value === undefined ? name : `${name}:${JSON.stringify(value)}`)
}
const accept = (value: Date | string | null) => {
record(accepted.value, 'update', value)
bound.value = value
}
const reset = () => {
bound.value = '09:30:00'
accepted.value = []
rejected.value = []
}
</script>
<template>
<HuiSpace class="time-picker-clear-demo" direction="vertical" fill>
<span
>The method and icon share clearing logic, emitting update→clear→change. Fixed parent values
retain the actual time.</span
>
<HuiSpace class="time-clear-bound" wrap>
<span>Parent accepts</span>
<HuiTimePicker
ref="boundRef"
:model-value="bound"
clearable
style="width: 200px"
@update:model-value="accept"
@clear="record(accepted, 'clear')"
@change="record(accepted, 'change', $event)"
/>
<HuiButton class="time-clear-accept" @click="boundRef?.clear()"
>Clear through method</HuiButton
>
<HuiButton class="time-clear-focus" @click="boundRef?.focus()">Focus</HuiButton>
<HuiButton class="time-clear-blur" @click="boundRef?.blur()">Blur</HuiButton>
</HuiSpace>
<span class="time-clear-value">Actual model: {{ JSON.stringify(bound) }}</span>
<span class="time-clear-accepted">{{ accepted.join(' → ') || 'No notifications yet' }}</span>
<HuiSpace class="time-clear-fixed" wrap>
<span>Parent fixes 09:30</span>
<HuiTimePicker
ref="fixedRef"
model-value="09:30:00"
clearable
style="width: 200px"
@update:model-value="record(rejected, 'update', $event)"
@clear="record(rejected, 'clear')"
@change="record(rejected, 'change', $event)"
/>
<HuiButton class="time-clear-reject" @click="fixedRef?.clear()">Request clearing</HuiButton>
</HuiSpace>
<span class="time-clear-rejected">{{ rejected.join(' → ') || 'No notifications yet' }}</span>
<HuiButton class="time-clear-reset" @click="reset">Restore example</HuiButton>
</HuiSpace>
</template>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| modelValue | Date | string | null | - | Bound value for v-model. Strings are parsed by valueFormat; invalid or out-of-range values are treated as empty. Clearing produces null. Omitted/listener-only models store null internally; supplied values are controlled, including undefined/null as empty |
| format | string | 'HH:mm:ss' | Display format and panel columns |
| valueFormat | string | - | Bound value format; see Bound Value Format |
| placeholder | string | Localized time-selection prompt | Placeholder when empty |
| clearable | boolean | false | Whether to show the clear button when nonempty |
| editable | boolean | true | Whether manual typing is allowed |
| disabled | boolean | false | Whether the picker is disabled |
| readonly | boolean | false | Whether the picker is read only |
| validateEvent | boolean | true | Validate changes or focus leaving the whole control. Internal focus moves or closing back to the trigger do not run blur validation |
| size | 'large' | 'default' | 'small' | — | Follows the form, then HuiConfigProvider, then default |
Events
| Event | Callback Arguments | Description |
|---|---|---|
| update:modelValue | (value: Date | string | null) | Confirmation, complete typed time or clearing, with null when clearing |
| change | (value: Date | string | null) | Same triggers as update:modelValue. Confirm emits even for an unchanged time |
| clear | - | Clear icon or clear() invocation |
| focus | (event: FocusEvent) | Focus enters the trigger or panel from outside the control; internal moves do not emit again |
| blur | (event: FocusEvent) | Focus leaves both trigger and panel. Internal moves or closing back to the trigger do not emit blur |
Slots
No slots.
Methods
Call through a component ref.
| Method | Arguments | Return Value | Description |
|---|---|---|---|
| focus | - | void | Focus the actual trigger without opening the panel; calling from the panel returns to the trigger |
| blur | - | void | Remove focus currently inside the trigger or panel from the whole control |
| clear | - | void | Requests null. Disabled, read-only and unmounted calls have no effect; rejected requests still display the actual parent time |
Types
type TimePickerSize = 'large' | 'default' | 'small'
interface TimePickerExpose {
focus: () => void
blur: () => void
clear: () => void
}
/** @deprecated Use TimePickerExpose; removed in 1.0. */
type TimePickerInstance = TimePickerExpose