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.
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`. |
| 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. |
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. |