2021-09-25 08:51:32 +00:00
---
category: Components
type: Data Entry
title: TimePicker
2023-02-17 02:03:34 +00:00
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*kGmGSLk_1fwAAAAAAAAAAAAADrJ8AQ/original
2023-03-20 03:15:02 +00:00
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*1hDmQJIDFJQAAAAAAAAAAAAADrJ8AQ/original
2021-09-25 08:51:32 +00:00
---
To select/input a time.
## When To Use
By clicking the input box, you can select a time from a popup panel.
## API
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| allowClear | Whether allow clearing text | boolean | true | |
| autofocus | If get focus when component mounted | boolean | false | |
| bordered | Whether has border style | boolean | true | |
| clearIcon | The custom clear icon | v-slot:clearIcon | - | |
| clearText | The clear tooltip of icon | string | clear | |
| disabled | Determine whether the TimePicker is disabled | boolean | false | |
2023-04-21 14:29:04 +00:00
| disabledTime | To specify the time that cannot be selected | [DisabledTime ](#disabledtime ) | - | 3.3.0 |
2021-09-25 08:51:32 +00:00
| format | To set the time format | string | `HH:mm:ss` | |
| getPopupContainer | To set the container of the floating layer, while the default is to create a div element in body | function(trigger) | - | |
| hideDisabledOptions | Whether hide the options that can not be selected | boolean | false | |
| hourStep | Interval between hours in picker | number | 1 | |
| inputReadOnly | Set the `readonly` attribute of the input tag (avoids virtual keyboard on touch devices) | boolean | false | |
| minuteStep | Interval between minutes in picker | number | 1 | |
| open(v-model) | Whether to popup panel | boolean | false | |
| placeholder | Display when there's no value | string \| \[string, string] | `Select a time` | |
2022-05-21 14:23:52 +00:00
| placement | The position where the selection box pops up | `bottomLeft` `bottomRight` `topLeft` `topRight` | bottomLeft | |
2021-09-25 08:51:32 +00:00
| popupClassName | The className of panel | string | - | |
| popupStyle | The style of panel | CSSProperties | - | |
| renderExtraFooter | Called from time picker panel to render some addon to its bottom | v-slot:renderExtraFooter | - | |
| secondStep | Interval between seconds in picker | number | 1 | |
| showNow | Whether to show `Now` button on panel | boolean | - | |
| suffixIcon | The custom suffix icon | v-slot:suffixIcon | - | |
| use12Hours | Display as 12 hours format, with default format `h:mm:ss a` | boolean | false | |
| value(v-model) | To set time | [dayjs ](https://day.js.org/ ) | - | |
| valueFormat | optional, format of binding value. If not specified, the binding value will be a Date object | string, [date formats](https://day.js.org/docs/en/display/format) | - | |
2022-05-21 14:23:52 +00:00
#### DisabledTime
```typescript
type DisabledTime = (now: Dayjs) => {
disabledHours?: () => number[];
disabledMinutes?: (selectedHour: number) => number[];
disabledSeconds?: (selectedHour: number, selectedMinute: number) => number[];
};
```
2021-09-25 08:51:32 +00:00
### events
| Events Name | Description | Arguments |
| --- | --- | --- |
| change | a callback function, can be executed when the selected time is changing | function(time: dayjs \| string, timeString: string): void |
| openChange | a callback function which will be called while panel opening/closing | (open: boolean): void |
## Methods
| Name | Description |
| ------- | ------------ |
| blur() | remove focus |
| focus() | get focus |
### TimeRangePicker
2023-04-21 14:29:04 +00:00
Same props from [RangePicker ](/components/date-picker/#rangepicker ) of DatePicker. And includes additional props:
2021-09-25 08:51:32 +00:00
2022-05-21 14:23:52 +00:00
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| order | Order start and end time | boolean | true | |
2023-04-21 14:29:04 +00:00
| disabledTime | To specify the time that cannot be selected | [RangeDisabledTime ](#rangedisabledtime ) | - | 3.3.0 |
2022-05-21 14:23:52 +00:00
#### RangeDisabledTime
```typescript
type RangeDisabledTime = (
now: Dayjs,
type = 'start' | 'end',
) => {
disabledHours?: () => number[];
disabledMinutes?: (selectedHour: number) => number[];
disabledSeconds?: (selectedHour: number, selectedMinute: number) => number[];
};
```
2021-09-25 08:51:32 +00:00
## FAQ
2021-12-04 17:06:31 +00:00
2021-09-25 08:51:32 +00:00
### How to use DatePicker with customize date library( like moment.js \| dayjs \| date-fns) ?
2021-12-04 17:06:31 +00:00
Please refer [replace date ](/docs/vue/replace-date )