TimePicker
Alpha.10
Available in Mavis alpha.11 for Vue Web and NativeScript. Keep core and renderer versions aligned.
<MTimePicker v-model="time" label="Meeting time" min="08:00" max="18:00" :minuteStep="15" />| Property | Type | Default | Description |
|---|---|---|---|
modelValue / v-model | HH:mm / null | null | Canonical wall-clock time. |
draft / v-model:draft | string | — | Optional controlled editor text. |
label | string | required | Visible field label. |
locale | en-US / pt-BR | en-US | Default display cycle. |
hourCycle | h12 / h23 | locale | Explicit 12/24-hour display. |
min / max | HH:mm | 00:00 / 23:59 | Inclusive same-day bounds. |
minuteStep | number | 1 | Divisor of 60 from 1 to 30. |
disabled / readonly | boolean | false | Prevents edits and picker opening. |
name | string | — | Web hidden field submits the canonical model. |
The editor displays h:mm AM/PM for en-US and HH:mm for pt-BR unless hourCycle is explicit. Incomplete text remains visible without replacing the last valid model. validityChange reports empty, valid, incomplete, invalid, range or step; use it to block application submission while a draft is invalid. update:draft, focus and blur are shared events; public handles provide focus()/blur(). Picker changes are provisional until Apply; Cancel leaves the model unchanged. Web uses labeled hour/minute/period controls; iOS and Android use the system TimePicker in MSheet. Bounds and interval are validated before confirmation; native wheels may show a value that cannot be confirmed. required disables Clear; business validation remains app-owned. Localize action, field and error labels.
A time alone is not an instant: there is no timezone or automatic DST conversion on this component. Combine a civil date, time and explicit timezone in your domain before producing an instant, and use the existing formatDateTime helper to display that instant. formatTime, parseTime and validateTime perform deterministic time-only formatting and validation on all renderers, including SSR. Overnight min/max ranges are rejected.
Inside the sheet, a large readout shows the provisional time. Hour, minutes and period roll up when they move forward and down when they move back, taking the short way around the clock. The readout is decorative and hidden from assistive technology; the labeled controls and native wheels stay the exact way to choose. A refused time, whether its error appears or the parent rejects it, shakes the field once.
Beside the readout, a glyph shows the part of the day for the provisional time: a moon until 05:00, a sunrise until 08:00, a sun until 17:00, a sunset until 20:00 and the moon again after that. It pops in when the part changes, is decorative and is hidden with the readout. Core exports the same rule as dayPart(time).
<script setup lang="ts">
import { computed, ref } from 'vue'
import { useCatalogLocale } from '../locale'
const props = defineProps<{ lang?: 'en' | 'pt' }>()
const { locale } = useCatalogLocale(() => props.lang)
const pt = computed(() => (props.lang ?? locale.value) === 'pt')
const t = (en: string, br: string) => (pt.value ? br : en)
const time = ref<string | null>('09:30')
</script>
<template>
<MColumn gap="md">
<MTimePicker
v-model="time"
:label="t('Meeting time', 'Horário do encontro')"
:locale="pt ? 'pt-BR' : 'en-US'"
min="08:00"
max="18:00"
:minuteStep="15"
name="meeting-time"
:helperText="t('08:00–18:00, every 15 minutes.', '08:00–18:00, a cada 15 minutos.')"
:chooseLabel="t('Choose time', 'Escolher horário')"
:confirmLabel="t('Apply', 'Aplicar')"
:cancelLabel="t('Cancel', 'Cancelar')"
:clearLabel="t('Clear time', 'Limpar horário')"
:hourLabel="t('Hour', 'Hora')"
:minuteLabel="t('Minute', 'Minuto')"
:periodLabel="t('Period', 'Período')"
:invalidLabel="
t(
'Choose a time between 08:00 and 18:00 in 15-minute intervals.',
'Escolha entre 08:00 e 18:00, em intervalos de 15 minutos.',
)
"
/>
<MText id="time-value" :text="time ?? '—'" tone="muted" />
</MColumn>
</template>Desktop
The clock action opens a layer under the field with the hour, the minutes and, on a 12-hour clock, the period: each is a button that the arrow keys, Page Up and Page Down step, with minus and plus buttons beside it, instead of a wheel. The hour cycle follows the locale or hourCycle, and name has no effect. See Desktop components.