Back to Element Plus

TimePicker

docs/en-US/component/time-picker.md

2.13.713.0 KB
Original Source

TimePicker

Use Time Picker for time input.

Arbitrary time picker

Can pick an arbitrary time.

:::demo By default, you can scroll the mouse wheel to pick time, alternatively you can use the control arrows when the arrow-control attribute is set.

time-picker/basic

:::

Limit the time range

You can also limit the time range.

:::demo Limit the time range by specifying disabledHours disabledMinutes and disabledSeconds.

time-picker/basic-range

:::

Arbitrary time range

Can pick an arbitrary time range.

:::demo We can pick a time range by adding an is-range attribute. Also, arrow-control is supported in range mode.

time-picker/range

:::

API

Attributes

NameDescriptionTypeDefault
model-value / v-modelbinding value, if it is an array, the length should be 2^[number] / ^[string] / ^[object]Date | [Date, Date] | [number, number] | [string, string]''
readonlywhether TimePicker is read only^[boolean]false
disabledwhether TimePicker is disabled^[boolean]false
editablewhether the input is editable^[boolean]true
clearablewhether to show clear button^[boolean]true
sizesize of Input^[enum]'large' | 'default' | 'small'
placeholderplaceholder in non-range mode^[string]''
start-placeholderplaceholder for the start time in range mode^[string]
end-placeholderplaceholder for the end time in range mode^[string]
is-rangewhether to pick a time range^[boolean]false
arrow-controlwhether to pick time using arrow buttons^[boolean]false
popper-classcustom class name for TimePicker's dropdown^[string]''
popper-stylecustom style for TimePicker's dropdown^[string] / ^[object]
popper-optionsCustomized popper option see more at popper.js^[object]Partial<PopperOptions>{}
fallback-placements ^(2.8.4)list of possible positions for Tooltip popper.js^[array]Placement[]['bottom', 'top', 'right', 'left']
placement ^(2.8.4)position of dropdownPlacementbottom
range-separatorrange separator^[string]'-'
formatformat of the displayed value in the input box^[string] see date formats
default-valueoptional, default date of the calendar^[Date] / ^[array][Date, Date]
value-formatoptional, format of binding value. If not specified, the binding value will be a Date object^[string] see date formats
idsame as id in native input^[string] / ^[array][string, string]
namesame as name in native input^[string]''
aria-label ^(a11y) ^(2.7.2)same as aria-label in native input^[string]
prefix-iconCustom prefix icon component^[string] / ^[Component]Clock
clear-iconCustom clear icon component^[string] / ^[Component]CircleClose
disabled-hoursTo specify the array of hours that cannot be selected^[Function](role: string, comparingDate?: Dayjs) => number[]
disabled-minutesTo specify the array of minutes that cannot be selected^[Function](hour: number, role: string, comparingDate?: Dayjs) => number[]
disabled-secondsTo specify the array of seconds that cannot be selected^[Function](hour: number, minute: number, role: string, comparingDate?: Dayjs) => number[]
teleportedwhether time-picker dropdown is teleported to the body^[boolean]true
tabindexinput tabindex^[string] / ^[number]0
empty-values ^(2.7.0)empty values of component, see config-provider^[array]
value-on-clear ^(2.7.0)clear return value, see config-provider^[string] / ^[number] / ^[boolean] / ^[Function]
save-on-blur ^(2.13.4)Whether to auto-fill the input with the current time on focus when no value is selected^[boolean]true
label ^(a11y) ^(deprecated)same as aria-label in native input^[string]

Events

NameDescriptionType
changetriggers when user confirms the value^[Function](val: number | string | Date | [number, number] | [string, string] | [Date, Date]) => void
blurtriggers when Input blurs^[Function](e: FocusEvent) => void
focustriggers when Input focuses^[Function](e: FocusEvent) => void
clear ^(2.7.7)triggers when the clear icon is clicked in a clearable TimePicker^[Function]() => void
visible-changetriggers when the TimePicker's dropdown appears/disappears^[Function](visibility: boolean) => void

Exposes

NameDescriptionType
focusfocus the TimePicker component^[Function]() => void
blurblur the TimePicker component^[Function]() => void
handleOpen ^(2.2.16)open the TimePicker popper^[Function]() => void
handleClose ^(2.2.16)close the TimePicker popper^[Function]() => void

Type Declarations

<details> <summary>Show declarations</summary>
ts
type Placement =
  | 'top'
  | 'top-start'
  | 'top-end'
  | 'bottom'
  | 'bottom-start'
  | 'bottom-end'
  | 'left'
  | 'left-start'
  | 'left-end'
  | 'right'
  | 'right-start'
  | 'right-end'
</details>