WlTimePicker

Native local time selection with minute precision; no date or time zone.
Components / Inputs v0.8.0

Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.

Settings

size

Field size.

density

Density.

minTime

Lower HH:mm boundary; minTime > maxTime defines an overnight range.

maxTime

Upper HH:mm boundary.

Disables selection.

External error state.

Props pt, step, hourFormat, allowedIntervals, models, handlers and slots can be edited in the SFC. See their descriptions in API.

Example

From 08:00 to 18:00. Clearing the field sets the model to null.

Selected: 09:30

Focus: outside the example · pointer: outside the example

Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.

Code for your application

Vue SFC · current settings
<script setup lang="ts">
import { WlField, WlTimePicker } from "legato-ui";
import { ref } from "vue";
const value = ref<string | null>("09:30");
</script>

<template>
  <div class="wl-stack" data-space="md">
    <WlField
      id="example-time"
      v-slot="field"
      label="Meeting time"
      hint="From 08:00 to 18:00. Clearing the field sets the model to null."
    >
      <WlTimePicker
        :id="field.id"
        v-model="value"
        :aria-describedby="field.ariaDescribedby"
        min-time="08:00"
        max-time="18:00"
        :hour-format="12"
        :step="900"
        :allowed-intervals="[{ start: '08:00', end: '12:00' }, { start: '13:00', end: '18:00' }]"
        
      />
    </WlField>
    <p class="wl-text-small" role="status">{{ "Selected:" }} {{ value ?? "no time set" }}</p>
  </div>
</template>

Time, limits and states

Three sizes, compact density, daytime and overnight ranges, error and clearing a nullable model.

Sizes and daytime range

From 08:00 to 18:00.
From 08:00 to 18:00.
From 08:00 to 18:00.

Overnight range, error and disabled

From 22:00 to 02:00: the range crosses midnight.

The model is HH:mm or null, without a date or time zone. An empty field clears the model; an invalid time does not replace the last valid value.

Meeting: 09:30. Night shift: 23:30.

Vue SFC · additional example
<script setup lang="ts">
import { WlButton, WlField, WlTimePicker } from "legato-ui";
import { ref } from "vue";
const appointment = ref<string | null>("09:30");
const night = ref<string | null>("23:30");
</script>

<template>
  <div class="wl-stack" data-space="xl" data-input-example="WlTimePicker">
    <section class="wl-stack" data-space="md">
      <h3 class="wl-text-title">{{ "Sizes and daytime range" }}</h3>
      <div class="wl-grid" data-space="lg">
        <WlField
          v-for="size in ['sm', 'md', 'lg'] as const"
          :id="`docs-time-${size}`"
          :key="size"
          v-slot="{ id, ariaDescribedby }"
          :label="`${'Meeting time, '}${size}`"
          hint="From 08:00 to 18:00."
        ><WlTimePicker
          :id="id"
          v-model="appointment"
          :size="size"
          min-time="08:00"
          max-time="18:00"
          :aria-describedby="ariaDescribedby"
        /></WlField>
        <WlField id="docs-time-compact" v-slot="{ id }" label="Compact time"><WlTimePicker
          :id="id"
          v-model="appointment"
          min-time="08:00"
          max-time="18:00"
          density="compact"
        /></WlField>
      </div>
    </section>
    <section class="wl-stack" data-space="md">
      <h3 class="wl-text-title">{{ "Overnight range, error and disabled" }}</h3>
      <div class="wl-grid" data-space="lg">
        <WlField
          id="docs-time-night"
          v-slot="{ id, ariaDescribedby }"
          label="Night shift"
          hint="From 22:00 to 02:00: the range crosses midnight."
        ><WlTimePicker
          :id="id"
          v-model="night"
          min-time="22:00"
          max-time="02:00"
          :aria-describedby="ariaDescribedby"
        /></WlField>
        <WlField
          id="docs-time-required"
          v-slot="{ id, ariaDescribedby, invalid, required }"
          label="Required meeting time"
          :error="appointment ? undefined : 'Enter a meeting time.'"
          required
        ><WlTimePicker
          :id="id"
          v-model="appointment"
          min-time="08:00"
          max-time="18:00"
          :invalid="invalid"
          :required="required"
          :aria-describedby="ariaDescribedby"
        /></WlField>
        <WlField id="docs-time-disabled" v-slot="{ id }" label="Unavailable time">
          <WlTimePicker :id="id" model-value="10:00" disabled />
        </WlField>
      </div>
      <p class="wl-text-small wl-text-muted">{{ "The model is HH:mm or null, without a date or time zone. An empty field clears the model; an invalid time does not replace the last valid value." }}</p>
      <div class="wl-inline" data-space="sm">
        <WlButton size="sm" @click="appointment = null; night = null">{{ "Clear time" }}</WlButton>
        <WlButton size="sm" @click="appointment = '09:30'; night = '23:30'">{{ "Reset time" }}</WlButton>
      </div>
      <p class="wl-text-small" role="status">{{
        "Meeting:"
      }} {{
        appointment ?? 'null'
      }}{{
        ". Night shift:"
      }} {{
        night ?? 'null'
      }}.</p>
    </section>
  </div>
</template>