TimePicker
A time of day, typed freely or picked from a list, and kept as minutes past midnight rather than a Date.
Import
import { TimePicker } from '@vitral/vue';Default
Half-hourly by default. The box shows the time the way the locale writes it; the value underneath is a number.
Typed, not chosen
A time box is a place people type. Try `9`, `930`, `9:30`, `9h30`, `21:30` or `9 pm` — then leave the box. Something that names no time empties it rather than guessing. The mask is off here, with `:mask="false"`, so any of these can be typed.
In the shape of the time
On a twenty-four-hour clock the box types into `__:__` by default: digits only, the colon typed for you, and half a time put back when the box is left. A time pasted whole, as `930` or `9:30`, is read before the mask sees it. A twelve-hour time has an hour of no fixed width and is left free.
Bounded, and stepped
`min-time` and `max-time` decide what the list offers and clamp what is typed; `step` decides how close together the times are. Page Up and Page Down move the value itself by an hour.
Twelve or twenty-four
`hour12` overrides what the locale would have written. The list and the box always agree, because both are built from the same number.
Inline
Without the text box or the popup.
API
Read from packages/vue/src/components/TimePicker/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| step | number | Minutes between the times the list offers. Defaults to 30. |
| minTime | number | string | null | The earliest time, as minutes past midnight or `'09:00'`. |
| maxTime | number | string | null | The latest, likewise. |
| hour12 | boolean | Force twelve- or twenty-four-hour; defaults to what the locale writes. |
| seconds | boolean | Show seconds in what is written; the list is still built from `step`. |
| mask | boolean | MaskProp | Whether the text box types into the shape the time is written in. On by default on a twenty-four-hour clock (`99:99`, or `99:99:99` with seconds); a twelve-hour time, whose hour has no fixed width, is left free. `false` leaves the box free; a mask of your own, as InputMask takes, replaces the derived one. |
| placeholder | string | — |
| inline | boolean | Show the list in place, without a text box or popup. |
| showClearButton | boolean | A footer button that empties the value. |
| size | Size | — |
| variant | InputVariant | Defaults to the plugin's `inputVariant`. |
| invalid | boolean | — |
| disabled | boolean | — |
| readonly | boolean | — |
| fluid | boolean | — |
| placement | OverlayPlacement | — |
| appendTo | string | `'body'` (the default), `'self'` to render in place, or a selector. |
| scrollbar | ScrollbarMode | The bars of the boxes this component scrolls inside — `'hover'`, `'always'` or `'native'`. The application's `scrollbar` option by default, which is `'hover'`. |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Emits
| Event | Payload | Description |
|---|---|---|
| timeSelect | minutes: number | A time was chosen from the list, or typed and committed. |
| clear | — | — |
| show | — | — |
| hide | — | — |
| focus | event: FocusEvent | — |
| blur | event: FocusEvent | — |
Slots
| Name | Slot props | Description |
|---|---|---|
| dropdownicon | — | The icon in the button that opens the list. |
| option | (props: { minutes: number; label: string; selected: boolean }) | One time in the list. |
| footer | (props: { minutes: number | null; clear: () => void }) | Under the list: a note, a pair of buttons. |