Skip to content

Time Picker ​

A field to type a time in, and a list, columns or a clock face in a popup to pick one.

vue
<script setup lang="ts">
import { useId } from 'vue';
import { TimeField } from '@vase-ui/vue/time-field';
import { TimePicker } from '@vase-ui/vue/time-picker';
import { Popover } from '@vase-ui/vue/popover';
import styles from '../../_index.module.css';

const id = useId();
const defaultValue = Temporal.PlainTime.from('09:30');

const popupHiddenClass = styles.PopupHidden;
</script>

<template>
  <div :class="styles.Field">
    <label :for="id" :class="styles.Label">Meeting time</label>
    <TimePicker.Root :default-value="defaultValue" locale="en-US" :hour-cycle="12">
      <div :class="styles.Control">
        <TimePicker.Field :id="id" :class="styles.Group">
          <TimeField.Input :class="styles.Input">
            <template #segment="{ segment }">
              <TimeField.Segment
                v-if="segment.editable"
                :segment="segment"
                :class="styles.Segment"
              />
              <TimeField.Literal v-else :segment="segment" :class="styles.Literal" />
            </template>
          </TimeField.Input>
        </TimePicker.Field>
        <TimePicker.Trigger aria-label="Choose time" :class="styles.Trigger">
          <svg
            aria-hidden="true"
            width="16"
            height="16"
            viewBox="0 0 16 16"
            fill="none"
            stroke="currentColor"
            stroke-linecap="square"
          >
            <circle cx="8" cy="8" r="5.5" />
            <path d="M8 4.5V8l2.5 1.5" />
          </svg>
        </TimePicker.Trigger>
      </div>
      <Popover.Portal>
        <TimePicker.Positioner :side-offset="4">
          <Transition :enter-from-class="popupHiddenClass" :leave-to-class="popupHiddenClass">
            <TimePicker.Popup aria-label="Choose a meeting time" :class="styles.Popup">
              <TimePicker.List aria-label="Times" :class="styles.List">
                <template #item="{ time }">
                  <TimePicker.Item :time="time" :class="styles.Item" />
                </template>
              </TimePicker.List>
            </TimePicker.Popup>
          </Transition>
        </TimePicker.Positioner>
      </Popover.Portal>
    </TimePicker.Root>
  </div>
</template>
css
.Field {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: 0.25rem;
}

.Label {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 700;
  color: oklch(14.5% 0 0deg);

  @media (prefers-color-scheme: dark) {
    color: white;
  }
}

.Control {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  height: 2rem;
  border: 1px solid oklch(14.5% 0 0deg);
  background-color: white;
  color: oklch(14.5% 0 0deg);

  @media (prefers-color-scheme: dark) {
    border-color: white;
    background-color: oklch(14.5% 0 0deg);
    color: white;
  }

  &:focus-within {
    outline: 2px solid oklch(14.5% 0 0deg);
    outline-offset: -1px;

    @media (prefers-color-scheme: dark) {
      outline-color: white;
    }
  }
}

.Group {
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
}

.Input {
  display: flex;
  align-items: center;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;

  @media (any-pointer: coarse) {
    font-size: 1rem;
    line-height: 1.5rem;
  }
}

.Segment {
  /* The box follows the text. A browser with no `field-sizing` keeps the width of `size`. */
  field-sizing: content;
  margin: 0;
  padding: 0 0.125rem;
  border: 0;
  border-radius: 0;
  outline: 0;
  font: inherit;
  text-align: center;
  caret-color: transparent;
  background-color: transparent;
  color: inherit;

  &::placeholder {
    color: oklch(55.6% 0 0deg);

    @media (prefers-color-scheme: dark) {
      color: oklch(70.8% 0 0deg);
    }
  }

  &:focus {
    background-color: oklch(14.5% 0 0deg);
    color: white;

    @media (prefers-color-scheme: dark) {
      background-color: white;
      color: oklch(14.5% 0 0deg);
    }

    &::placeholder {
      color: oklch(70.8% 0 0deg);

      @media (prefers-color-scheme: dark) {
        color: oklch(43.9% 0 0deg);
      }
    }
  }
}

.Literal {
  color: oklch(43.9% 0 0deg);
  white-space: pre;

  @media (prefers-color-scheme: dark) {
    color: oklch(70.8% 0 0deg);
  }
}

.Trigger {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.875rem;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid oklch(14.5% 0 0deg);
  border-radius: 0;
  font: inherit;
  color: inherit;
  background-color: transparent;
  user-select: none;

  @media (prefers-color-scheme: dark) {
    border-left-color: white;
  }

  @media (hover: hover) {
    &:hover:not(:disabled) {
      background-color: oklch(97% 0 0deg);

      @media (prefers-color-scheme: dark) {
        background-color: oklch(26.9% 0 0deg);
      }
    }
  }

  &[aria-expanded='true'] {
    background-color: oklch(97% 0 0deg);

    @media (prefers-color-scheme: dark) {
      background-color: oklch(26.9% 0 0deg);
    }
  }

  &:disabled {
    color: oklch(55.6% 0 0deg);

    @media (prefers-color-scheme: dark) {
      color: oklch(70.8% 0 0deg);
    }
  }

  &:focus-visible {
    outline: 2px solid oklch(14.5% 0 0deg);
    outline-offset: -1px;

    @media (prefers-color-scheme: dark) {
      outline-color: white;
    }
  }
}

.Popup {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem;
  outline: none;
  border: 1px solid oklch(14.5% 0 0deg);
  background-color: white;
  color: oklch(14.5% 0 0deg);
  box-shadow: 0.25rem 0.25rem 0 rgb(0 0 0 / 12%);
  transform-origin: var(--transform-origin);
  transition:
    transform 100ms ease-out,
    opacity 100ms ease-out;

  @media (prefers-color-scheme: dark) {
    border-color: white;
    background-color: oklch(14.5% 0 0deg);
    color: white;
    box-shadow: none;
  }
}

/* The enter-from and leave-to class of the `<Transition>` around the popup. */
.PopupHidden {
  opacity: 0;
  transform: scale(0.98);
}

.List,
.Column {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  max-height: 14rem;
  overflow-y: auto;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.List {
  width: 8rem;
}

.Columns {
  display: flex;
  gap: 0.5rem;
}

.Column {
  width: 3.5rem;
}

.Item {
  box-sizing: border-box;
  margin: 0;
  border: 0;
  font: inherit;
  color: inherit;
  background-color: transparent;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  height: 2rem;
  padding: 0 0.75rem;
  border-radius: 0.375rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;

  &:hover:not([aria-selected='true']):not(:disabled) {
    background-color: oklch(97% 0 0deg);

    @media (prefers-color-scheme: dark) {
      background-color: oklch(26.9% 0 0deg);
    }
  }

  &[aria-selected='true'] {
    background-color: oklch(14.5% 0 0deg);
    color: white;

    @media (prefers-color-scheme: dark) {
      background-color: white;
      color: oklch(14.5% 0 0deg);
    }
  }

  &:disabled {
    opacity: 0.4;
    cursor: default;
  }

  &:focus-visible {
    outline: 2px solid oklch(14.5% 0 0deg);
    outline-offset: -2px;

    @media (prefers-color-scheme: dark) {
      outline-color: white;
    }
  }

  &[aria-selected='true']:focus-visible {
    outline-color: white;

    @media (prefers-color-scheme: dark) {
      outline-color: oklch(14.5% 0 0deg);
    }
  }
}

.Clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: oklch(14.5% 0 0deg);

  @media (prefers-color-scheme: dark) {
    color: white;
  }
}

.Header {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.Separator {
  font-size: 1.25rem;
  font-weight: 700;
}

.ViewTrigger,
.DayPeriod {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  margin: 0;
  padding: 0 0.5rem;
  border: 1px solid oklch(14.5% 0 0deg);
  border-radius: 0;
  background-color: white;
  color: oklch(14.5% 0 0deg);
  font-family: inherit;
  font-size: 1.25rem;
  line-height: 1.5rem;
  font-variant-numeric: tabular-nums;
  -webkit-user-select: none;
  user-select: none;

  @media (prefers-color-scheme: dark) {
    border: 1px solid white;
    background-color: oklch(14.5% 0 0deg);
    color: white;
  }

  @media (hover: hover) {
    &:hover:not(:disabled, [aria-pressed='true']) {
      background-color: oklch(97% 0 0deg);

      @media (prefers-color-scheme: dark) {
        background-color: oklch(26.9% 0 0deg);
      }
    }
  }

  &:focus-visible {
    z-index: 1;
    outline: 2px solid oklch(14.5% 0 0deg);
    outline-offset: 2px;

    @media (prefers-color-scheme: dark) {
      outline-color: white;
    }
  }

  &[aria-pressed='true'] {
    background-color: oklch(14.5% 0 0deg);
    color: white;

    @media (prefers-color-scheme: dark) {
      background-color: white;
      color: oklch(14.5% 0 0deg);
    }
  }

  &:disabled {
    color: oklch(55.6% 0 0deg);
    border-color: oklch(55.6% 0 0deg);

    @media (prefers-color-scheme: dark) {
      color: oklch(70.8% 0 0deg);
      border-color: oklch(70.8% 0 0deg);
    }
  }
}

.DayPeriod {
  font-size: 0.875rem;
}

/*
 * The face is the containing block of the hand, the numbers and the range input of the part. The
 * parts write the angle and the radius as variables and set no position, so each rule below places
 * them.
 */
.Face {
  --radius: 5.5rem;

  position: relative;
  box-sizing: border-box;
  width: 14rem;
  height: 14rem;
  border: 1px solid oklch(14.5% 0 0deg);
  border-radius: 50%;
  background-color: oklch(97% 0 0deg);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;

  @media (prefers-color-scheme: dark) {
    border: 1px solid white;
    background-color: oklch(26.9% 0 0deg);
  }

  &:has(:focus-visible) {
    outline: 2px solid oklch(14.5% 0 0deg);
    outline-offset: 2px;

    @media (prefers-color-scheme: dark) {
      outline-color: white;
    }
  }

  &[data-disabled],
  &[data-readonly] {
    cursor: default;
  }
}

.Hand {
  position: absolute;
  bottom: 50%;
  left: 50%;
  width: 2px;
  height: calc(var(--time-clock-hand-length) * var(--radius));
  background-color: oklch(14.5% 0 0deg);
  translate: -50% 0;
  transform-origin: 50% 100%;
  transform: rotate(var(--time-clock-hand-angle));
  pointer-events: none;

  @media (prefers-color-scheme: dark) {
    background-color: white;
  }

  /* A time between two numbers has a tip and no selected number under it. */
  &[data-between-numbers]::after {
    content: '';
    position: absolute;
    top: -0.25rem;
    left: 50%;
    width: 0.5rem;
    height: 0.5rem;
    translate: -50% 0;
    border-radius: 50%;
    background-color: oklch(14.5% 0 0deg);

    @media (prefers-color-scheme: dark) {
      background-color: white;
    }
  }
}

.Number {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin: -1rem 0 0 -1rem;
  border-radius: 50%;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  pointer-events: none;

  /* Turn to the angle, move out by the radius, and turn back so that the digits stay upright. */
  transform: rotate(var(--time-clock-number-angle))
    translateY(calc(var(--time-clock-number-radius) * var(--radius) * -1))
    rotate(calc(var(--time-clock-number-angle) * -1));

  &[data-inner] {
    width: 1.75rem;
    height: 1.75rem;
    margin: -0.875rem 0 0 -0.875rem;
    font-size: 0.75rem;
  }

  &[data-selected] {
    background-color: oklch(14.5% 0 0deg);
    color: white;

    @media (prefers-color-scheme: dark) {
      background-color: white;
      color: oklch(14.5% 0 0deg);
    }
  }

  &[data-disabled] {
    color: oklch(43.9% 0 0deg);

    @media (prefers-color-scheme: dark) {
      color: oklch(70.8% 0 0deg);
    }
  }
}
vue
<script setup lang="ts">
import { useId } from 'vue';
import { TimeField } from '@vase-ui/vue/time-field';
import { TimePicker } from '@vase-ui/vue/time-picker';
import { Popover } from '@vase-ui/vue/popover';

const id = useId();
const defaultValue = Temporal.PlainTime.from('09:30');

const popupHiddenClass = 'scale-[0.98] opacity-0';
</script>

<template>
  <div class="flex flex-col items-start gap-1">
    <label :for="id" class="text-sm font-bold text-neutral-950 dark:text-white">Meeting time</label>
    <TimePicker.Root :default-value="defaultValue" locale="en-US" :hour-cycle="12">
      <div
        class="box-border flex h-8 items-center border border-neutral-950 bg-white text-neutral-950 focus-within:outline-2 focus-within:-outline-offset-1 focus-within:outline-neutral-950 dark:border-white dark:bg-neutral-950 dark:text-white dark:focus-within:outline-white"
      >
        <TimePicker.Field :id="id" class="flex items-center px-2">
          <TimeField.Input
            class="flex items-center text-sm font-normal tabular-nums any-pointer-coarse:text-base"
          >
            <template #segment="{ segment }">
              <TimeField.Segment
                v-if="segment.editable"
                :segment="segment"
                class="field-sizing-content px-0.5 text-center caret-transparent outline-0 placeholder:text-neutral-500 focus:bg-neutral-950 focus:text-white focus:placeholder:text-neutral-400 dark:placeholder:text-neutral-400 dark:focus:bg-white dark:focus:text-neutral-950 dark:focus:placeholder:text-neutral-600"
              />
              <TimeField.Literal
                v-else
                :segment="segment"
                class="whitespace-pre text-neutral-600 dark:text-neutral-400"
              />
            </template>
          </TimeField.Input>
        </TimePicker.Field>
        <TimePicker.Trigger
          aria-label="Choose time"
          class="box-border flex h-full w-[1.875rem] items-center justify-center border-0 border-l border-neutral-950 bg-transparent p-0 select-none hover:not-disabled:bg-neutral-100 disabled:text-neutral-500 aria-expanded:bg-neutral-100 focus-visible:outline-2 focus-visible:-outline-offset-1 focus-visible:outline-neutral-950 dark:border-white dark:hover:not-disabled:bg-neutral-800 dark:disabled:text-neutral-400 dark:aria-expanded:bg-neutral-800 dark:focus-visible:outline-white"
        >
          <svg
            aria-hidden="true"
            width="16"
            height="16"
            viewBox="0 0 16 16"
            fill="none"
            stroke="currentColor"
            stroke-linecap="square"
          >
            <circle cx="8" cy="8" r="5.5" />
            <path d="M8 4.5V8l2.5 1.5" />
          </svg>
        </TimePicker.Trigger>
      </div>
      <Popover.Portal>
        <TimePicker.Positioner :side-offset="4">
          <Transition :enter-from-class="popupHiddenClass" :leave-to-class="popupHiddenClass">
            <TimePicker.Popup
              aria-label="Choose a meeting time"
              class="box-border flex origin-[var(--transform-origin)] flex-col gap-3 border border-neutral-950 bg-white p-3 text-neutral-950 shadow-[0.25rem_0.25rem_0] shadow-black/12 outline-none transition-[scale,opacity] duration-100 ease-out dark:border-white dark:bg-neutral-950 dark:text-white dark:shadow-none"
            >
              <TimePicker.List
                aria-label="Times"
                class="box-border flex flex-col gap-0.5 overflow-y-auto text-sm tabular-nums max-h-56 w-32"
              >
                <template #item="{ time }">
                  <TimePicker.Item
                    :time="time"
                    class="border-0 bg-transparent box-border flex h-8 flex-none cursor-pointer items-center justify-center rounded-md px-3 whitespace-nowrap select-none hover:not-disabled:not-aria-selected:bg-neutral-100 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-neutral-950 disabled:cursor-default disabled:opacity-40 aria-selected:bg-neutral-950 aria-selected:text-white aria-selected:focus-visible:outline-white dark:hover:not-disabled:not-aria-selected:bg-neutral-800 dark:focus-visible:outline-white dark:aria-selected:bg-white dark:aria-selected:text-neutral-950 dark:aria-selected:focus-visible:outline-neutral-950"
                  />
                </template>
              </TimePicker.List>
            </TimePicker.Popup>
          </Transition>
        </TimePicker.Positioner>
      </Popover.Portal>
    </TimePicker.Root>
  </div>
</template>

Usage guidelines ​

  • The picker needs Temporal: Load a Temporal polyfill for an engine that has none, such as Safari and Node.js 24. Use TypeScript 6.0, or set skipLibCheck. See Dates and times.
  • Form controls must have an accessible name: Put the picker in a Field with a Field.Label, give TimePicker.Field an aria-label or an aria-labelledby, or point a <label for> at the id of TimePicker.Field. A <label for> names the field only after the mount, so the server HTML has no name for it. See the forms guide.
  • The trigger must have a name: Give TimePicker.Trigger content or an aria-label in the language of the page. See Show the time in the trigger.
  • The popup and the list must have a name: Give TimePicker.Popup an aria-label, or put a Popover.Title in it. Give TimePicker.List an aria-label or an aria-labelledby in the language of the page.

Anatomy ​

Import the component and assemble its parts:

vue
<script setup lang="ts">
import { TimeClock } from '@vase-ui/vue/time-clock';
import { TimeField } from '@vase-ui/vue/time-field';
import { TimePicker } from '@vase-ui/vue/time-picker';
import { Popover } from '@vase-ui/vue/popover';
</script>

<template>
  <TimePicker.Root>
    <TimePicker.Field>
      <TimeField.Input />
    </TimePicker.Field>
    <TimePicker.Trigger aria-label="Choose time" />
    <Popover.Portal>
      <TimePicker.Positioner>
        <TimePicker.Popup aria-label="Choose a time">
          <TimePicker.List aria-label="Times">
            <template #item="{ time }">
              <TimePicker.Item :time="time" />
            </template>
          </TimePicker.List>
          <TimePicker.Column unit="hour">
            <template #item="{ value }">
              <TimePicker.ColumnItem :value="value" />
            </template>
          </TimePicker.Column>
          <TimePicker.Clock>
            <TimeClock.ViewTrigger view="hour" />
            <TimeClock.ViewTrigger view="minute" />
            <TimeClock.DayPeriod value="am" />
            <TimeClock.DayPeriod value="pm" />
            <TimeClock.Face>
              <TimeClock.Hand />
              <template #number="{ number }">
                <TimeClock.Number :number="number" />
              </template>
            </TimeClock.Face>
          </TimePicker.Clock>
          <Popover.Close />
        </TimePicker.Popup>
      </TimePicker.Positioner>
    </Popover.Portal>
  </TimePicker.Root>
</template>

Examples ​

Columns ​

TimePicker.Column has a unit: hour, minute, second or dayPeriod. A press on a value sets that unit, keeps the other units, and leaves the popup open. An hour of a 12-hour cycle goes from 12 to 11, because 12 AM is the first hour of the day. A column of day periods renders nothing in a 24-hour cycle.

vue
<script setup lang="ts">
import { useId } from 'vue';
import { TimeField } from '@vase-ui/vue/time-field';
import { TimePicker } from '@vase-ui/vue/time-picker';
import { Popover } from '@vase-ui/vue/popover';
import styles from '../../_index.module.css';

const id = useId();
const defaultValue = Temporal.PlainTime.from('14:30');

const popupHiddenClass = styles.PopupHidden;
</script>

<template>
  <div :class="styles.Field">
    <label :for="id" :class="styles.Label">Start time</label>
    <TimePicker.Root :default-value="defaultValue" locale="en-US" :hour-cycle="12">
      <div :class="styles.Control">
        <TimePicker.Field :id="id" :class="styles.Group">
          <TimeField.Input :class="styles.Input">
            <template #segment="{ segment }">
              <TimeField.Segment
                v-if="segment.editable"
                :segment="segment"
                :class="styles.Segment"
              />
              <TimeField.Literal v-else :segment="segment" :class="styles.Literal" />
            </template>
          </TimeField.Input>
        </TimePicker.Field>
        <TimePicker.Trigger aria-label="Choose time" :class="styles.Trigger">
          <svg
            aria-hidden="true"
            width="16"
            height="16"
            viewBox="0 0 16 16"
            fill="none"
            stroke="currentColor"
            stroke-linecap="square"
          >
            <circle cx="8" cy="8" r="5.5" />
            <path d="M8 4.5V8l2.5 1.5" />
          </svg>
        </TimePicker.Trigger>
      </div>
      <Popover.Portal>
        <TimePicker.Positioner :side-offset="4">
          <Transition :enter-from-class="popupHiddenClass" :leave-to-class="popupHiddenClass">
            <TimePicker.Popup aria-label="Choose a start time" :class="styles.Popup">
              <div :class="styles.Columns">
                <TimePicker.Column unit="hour" :class="styles.Column">
                  <template #item="{ value }">
                    <TimePicker.ColumnItem :value="value" :class="styles.Item" />
                  </template>
                </TimePicker.Column>
                <TimePicker.Column unit="minute" :step="5" :class="styles.Column">
                  <template #item="{ value }">
                    <TimePicker.ColumnItem :value="value" :class="styles.Item" />
                  </template>
                </TimePicker.Column>
                <TimePicker.Column unit="dayPeriod" :class="styles.Column">
                  <template #item="{ value }">
                    <TimePicker.ColumnItem :value="value" :class="styles.Item" />
                  </template>
                </TimePicker.Column>
              </div>
            </TimePicker.Popup>
          </Transition>
        </TimePicker.Positioner>
      </Popover.Portal>
    </TimePicker.Root>
  </div>
</template>
css
.Field {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: 0.25rem;
}

.Label {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 700;
  color: oklch(14.5% 0 0deg);

  @media (prefers-color-scheme: dark) {
    color: white;
  }
}

.Control {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  height: 2rem;
  border: 1px solid oklch(14.5% 0 0deg);
  background-color: white;
  color: oklch(14.5% 0 0deg);

  @media (prefers-color-scheme: dark) {
    border-color: white;
    background-color: oklch(14.5% 0 0deg);
    color: white;
  }

  &:focus-within {
    outline: 2px solid oklch(14.5% 0 0deg);
    outline-offset: -1px;

    @media (prefers-color-scheme: dark) {
      outline-color: white;
    }
  }
}

.Group {
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
}

.Input {
  display: flex;
  align-items: center;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;

  @media (any-pointer: coarse) {
    font-size: 1rem;
    line-height: 1.5rem;
  }
}

.Segment {
  /* The box follows the text. A browser with no `field-sizing` keeps the width of `size`. */
  field-sizing: content;
  margin: 0;
  padding: 0 0.125rem;
  border: 0;
  border-radius: 0;
  outline: 0;
  font: inherit;
  text-align: center;
  caret-color: transparent;
  background-color: transparent;
  color: inherit;

  &::placeholder {
    color: oklch(55.6% 0 0deg);

    @media (prefers-color-scheme: dark) {
      color: oklch(70.8% 0 0deg);
    }
  }

  &:focus {
    background-color: oklch(14.5% 0 0deg);
    color: white;

    @media (prefers-color-scheme: dark) {
      background-color: white;
      color: oklch(14.5% 0 0deg);
    }

    &::placeholder {
      color: oklch(70.8% 0 0deg);

      @media (prefers-color-scheme: dark) {
        color: oklch(43.9% 0 0deg);
      }
    }
  }
}

.Literal {
  color: oklch(43.9% 0 0deg);
  white-space: pre;

  @media (prefers-color-scheme: dark) {
    color: oklch(70.8% 0 0deg);
  }
}

.Trigger {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.875rem;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid oklch(14.5% 0 0deg);
  border-radius: 0;
  font: inherit;
  color: inherit;
  background-color: transparent;
  user-select: none;

  @media (prefers-color-scheme: dark) {
    border-left-color: white;
  }

  @media (hover: hover) {
    &:hover:not(:disabled) {
      background-color: oklch(97% 0 0deg);

      @media (prefers-color-scheme: dark) {
        background-color: oklch(26.9% 0 0deg);
      }
    }
  }

  &[aria-expanded='true'] {
    background-color: oklch(97% 0 0deg);

    @media (prefers-color-scheme: dark) {
      background-color: oklch(26.9% 0 0deg);
    }
  }

  &:disabled {
    color: oklch(55.6% 0 0deg);

    @media (prefers-color-scheme: dark) {
      color: oklch(70.8% 0 0deg);
    }
  }

  &:focus-visible {
    outline: 2px solid oklch(14.5% 0 0deg);
    outline-offset: -1px;

    @media (prefers-color-scheme: dark) {
      outline-color: white;
    }
  }
}

.Popup {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem;
  outline: none;
  border: 1px solid oklch(14.5% 0 0deg);
  background-color: white;
  color: oklch(14.5% 0 0deg);
  box-shadow: 0.25rem 0.25rem 0 rgb(0 0 0 / 12%);
  transform-origin: var(--transform-origin);
  transition:
    transform 100ms ease-out,
    opacity 100ms ease-out;

  @media (prefers-color-scheme: dark) {
    border-color: white;
    background-color: oklch(14.5% 0 0deg);
    color: white;
    box-shadow: none;
  }
}

/* The enter-from and leave-to class of the `<Transition>` around the popup. */
.PopupHidden {
  opacity: 0;
  transform: scale(0.98);
}

.List,
.Column {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  max-height: 14rem;
  overflow-y: auto;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.List {
  width: 8rem;
}

.Columns {
  display: flex;
  gap: 0.5rem;
}

.Column {
  width: 3.5rem;
}

.Item {
  box-sizing: border-box;
  margin: 0;
  border: 0;
  font: inherit;
  color: inherit;
  background-color: transparent;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  height: 2rem;
  padding: 0 0.75rem;
  border-radius: 0.375rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;

  &:hover:not([aria-selected='true']):not(:disabled) {
    background-color: oklch(97% 0 0deg);

    @media (prefers-color-scheme: dark) {
      background-color: oklch(26.9% 0 0deg);
    }
  }

  &[aria-selected='true'] {
    background-color: oklch(14.5% 0 0deg);
    color: white;

    @media (prefers-color-scheme: dark) {
      background-color: white;
      color: oklch(14.5% 0 0deg);
    }
  }

  &:disabled {
    opacity: 0.4;
    cursor: default;
  }

  &:focus-visible {
    outline: 2px solid oklch(14.5% 0 0deg);
    outline-offset: -2px;

    @media (prefers-color-scheme: dark) {
      outline-color: white;
    }
  }

  &[aria-selected='true']:focus-visible {
    outline-color: white;

    @media (prefers-color-scheme: dark) {
      outline-color: oklch(14.5% 0 0deg);
    }
  }
}

.Clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: oklch(14.5% 0 0deg);

  @media (prefers-color-scheme: dark) {
    color: white;
  }
}

.Header {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.Separator {
  font-size: 1.25rem;
  font-weight: 700;
}

.ViewTrigger,
.DayPeriod {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  margin: 0;
  padding: 0 0.5rem;
  border: 1px solid oklch(14.5% 0 0deg);
  border-radius: 0;
  background-color: white;
  color: oklch(14.5% 0 0deg);
  font-family: inherit;
  font-size: 1.25rem;
  line-height: 1.5rem;
  font-variant-numeric: tabular-nums;
  -webkit-user-select: none;
  user-select: none;

  @media (prefers-color-scheme: dark) {
    border: 1px solid white;
    background-color: oklch(14.5% 0 0deg);
    color: white;
  }

  @media (hover: hover) {
    &:hover:not(:disabled, [aria-pressed='true']) {
      background-color: oklch(97% 0 0deg);

      @media (prefers-color-scheme: dark) {
        background-color: oklch(26.9% 0 0deg);
      }
    }
  }

  &:focus-visible {
    z-index: 1;
    outline: 2px solid oklch(14.5% 0 0deg);
    outline-offset: 2px;

    @media (prefers-color-scheme: dark) {
      outline-color: white;
    }
  }

  &[aria-pressed='true'] {
    background-color: oklch(14.5% 0 0deg);
    color: white;

    @media (prefers-color-scheme: dark) {
      background-color: white;
      color: oklch(14.5% 0 0deg);
    }
  }

  &:disabled {
    color: oklch(55.6% 0 0deg);
    border-color: oklch(55.6% 0 0deg);

    @media (prefers-color-scheme: dark) {
      color: oklch(70.8% 0 0deg);
      border-color: oklch(70.8% 0 0deg);
    }
  }
}

.DayPeriod {
  font-size: 0.875rem;
}

/*
 * The face is the containing block of the hand, the numbers and the range input of the part. The
 * parts write the angle and the radius as variables and set no position, so each rule below places
 * them.
 */
.Face {
  --radius: 5.5rem;

  position: relative;
  box-sizing: border-box;
  width: 14rem;
  height: 14rem;
  border: 1px solid oklch(14.5% 0 0deg);
  border-radius: 50%;
  background-color: oklch(97% 0 0deg);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;

  @media (prefers-color-scheme: dark) {
    border: 1px solid white;
    background-color: oklch(26.9% 0 0deg);
  }

  &:has(:focus-visible) {
    outline: 2px solid oklch(14.5% 0 0deg);
    outline-offset: 2px;

    @media (prefers-color-scheme: dark) {
      outline-color: white;
    }
  }

  &[data-disabled],
  &[data-readonly] {
    cursor: default;
  }
}

.Hand {
  position: absolute;
  bottom: 50%;
  left: 50%;
  width: 2px;
  height: calc(var(--time-clock-hand-length) * var(--radius));
  background-color: oklch(14.5% 0 0deg);
  translate: -50% 0;
  transform-origin: 50% 100%;
  transform: rotate(var(--time-clock-hand-angle));
  pointer-events: none;

  @media (prefers-color-scheme: dark) {
    background-color: white;
  }

  /* A time between two numbers has a tip and no selected number under it. */
  &[data-between-numbers]::after {
    content: '';
    position: absolute;
    top: -0.25rem;
    left: 50%;
    width: 0.5rem;
    height: 0.5rem;
    translate: -50% 0;
    border-radius: 50%;
    background-color: oklch(14.5% 0 0deg);

    @media (prefers-color-scheme: dark) {
      background-color: white;
    }
  }
}

.Number {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin: -1rem 0 0 -1rem;
  border-radius: 50%;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  pointer-events: none;

  /* Turn to the angle, move out by the radius, and turn back so that the digits stay upright. */
  transform: rotate(var(--time-clock-number-angle))
    translateY(calc(var(--time-clock-number-radius) * var(--radius) * -1))
    rotate(calc(var(--time-clock-number-angle) * -1));

  &[data-inner] {
    width: 1.75rem;
    height: 1.75rem;
    margin: -0.875rem 0 0 -0.875rem;
    font-size: 0.75rem;
  }

  &[data-selected] {
    background-color: oklch(14.5% 0 0deg);
    color: white;

    @media (prefers-color-scheme: dark) {
      background-color: white;
      color: oklch(14.5% 0 0deg);
    }
  }

  &[data-disabled] {
    color: oklch(43.9% 0 0deg);

    @media (prefers-color-scheme: dark) {
      color: oklch(70.8% 0 0deg);
    }
  }
}
vue
<script setup lang="ts">
import { useId } from 'vue';
import { TimeField } from '@vase-ui/vue/time-field';
import { TimePicker } from '@vase-ui/vue/time-picker';
import { Popover } from '@vase-ui/vue/popover';

const id = useId();
const defaultValue = Temporal.PlainTime.from('14:30');

const popupHiddenClass = 'scale-[0.98] opacity-0';
</script>

<template>
  <div class="flex flex-col items-start gap-1">
    <label :for="id" class="text-sm font-bold text-neutral-950 dark:text-white">Start time</label>
    <TimePicker.Root :default-value="defaultValue" locale="en-US" :hour-cycle="12">
      <div
        class="box-border flex h-8 items-center border border-neutral-950 bg-white text-neutral-950 focus-within:outline-2 focus-within:-outline-offset-1 focus-within:outline-neutral-950 dark:border-white dark:bg-neutral-950 dark:text-white dark:focus-within:outline-white"
      >
        <TimePicker.Field :id="id" class="flex items-center px-2">
          <TimeField.Input
            class="flex items-center text-sm font-normal tabular-nums any-pointer-coarse:text-base"
          >
            <template #segment="{ segment }">
              <TimeField.Segment
                v-if="segment.editable"
                :segment="segment"
                class="field-sizing-content px-0.5 text-center caret-transparent outline-0 placeholder:text-neutral-500 focus:bg-neutral-950 focus:text-white focus:placeholder:text-neutral-400 dark:placeholder:text-neutral-400 dark:focus:bg-white dark:focus:text-neutral-950 dark:focus:placeholder:text-neutral-600"
              />
              <TimeField.Literal
                v-else
                :segment="segment"
                class="whitespace-pre text-neutral-600 dark:text-neutral-400"
              />
            </template>
          </TimeField.Input>
        </TimePicker.Field>
        <TimePicker.Trigger
          aria-label="Choose time"
          class="box-border flex h-full w-[1.875rem] items-center justify-center border-0 border-l border-neutral-950 bg-transparent p-0 select-none hover:not-disabled:bg-neutral-100 disabled:text-neutral-500 aria-expanded:bg-neutral-100 focus-visible:outline-2 focus-visible:-outline-offset-1 focus-visible:outline-neutral-950 dark:border-white dark:hover:not-disabled:bg-neutral-800 dark:disabled:text-neutral-400 dark:aria-expanded:bg-neutral-800 dark:focus-visible:outline-white"
        >
          <svg
            aria-hidden="true"
            width="16"
            height="16"
            viewBox="0 0 16 16"
            fill="none"
            stroke="currentColor"
            stroke-linecap="square"
          >
            <circle cx="8" cy="8" r="5.5" />
            <path d="M8 4.5V8l2.5 1.5" />
          </svg>
        </TimePicker.Trigger>
      </div>
      <Popover.Portal>
        <TimePicker.Positioner :side-offset="4">
          <Transition :enter-from-class="popupHiddenClass" :leave-to-class="popupHiddenClass">
            <TimePicker.Popup
              aria-label="Choose a start time"
              class="box-border flex origin-[var(--transform-origin)] flex-col gap-3 border border-neutral-950 bg-white p-3 text-neutral-950 shadow-[0.25rem_0.25rem_0] shadow-black/12 outline-none transition-[scale,opacity] duration-100 ease-out dark:border-white dark:bg-neutral-950 dark:text-white dark:shadow-none"
            >
              <div class="flex gap-2">
                <TimePicker.Column
                  unit="hour"
                  class="box-border flex flex-col gap-0.5 overflow-y-auto text-sm tabular-nums max-h-56 w-14"
                >
                  <template #item="{ value }">
                    <TimePicker.ColumnItem
                      :value="value"
                      class="border-0 bg-transparent box-border flex h-8 flex-none cursor-pointer items-center justify-center rounded-md px-3 whitespace-nowrap select-none hover:not-disabled:not-aria-selected:bg-neutral-100 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-neutral-950 disabled:cursor-default disabled:opacity-40 aria-selected:bg-neutral-950 aria-selected:text-white aria-selected:focus-visible:outline-white dark:hover:not-disabled:not-aria-selected:bg-neutral-800 dark:focus-visible:outline-white dark:aria-selected:bg-white dark:aria-selected:text-neutral-950 dark:aria-selected:focus-visible:outline-neutral-950"
                    />
                  </template>
                </TimePicker.Column>
                <TimePicker.Column
                  unit="minute"
                  :step="5"
                  class="box-border flex flex-col gap-0.5 overflow-y-auto text-sm tabular-nums max-h-56 w-14"
                >
                  <template #item="{ value }">
                    <TimePicker.ColumnItem
                      :value="value"
                      class="border-0 bg-transparent box-border flex h-8 flex-none cursor-pointer items-center justify-center rounded-md px-3 whitespace-nowrap select-none hover:not-disabled:not-aria-selected:bg-neutral-100 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-neutral-950 disabled:cursor-default disabled:opacity-40 aria-selected:bg-neutral-950 aria-selected:text-white aria-selected:focus-visible:outline-white dark:hover:not-disabled:not-aria-selected:bg-neutral-800 dark:focus-visible:outline-white dark:aria-selected:bg-white dark:aria-selected:text-neutral-950 dark:aria-selected:focus-visible:outline-neutral-950"
                    />
                  </template>
                </TimePicker.Column>
                <TimePicker.Column
                  unit="dayPeriod"
                  class="box-border flex flex-col gap-0.5 overflow-y-auto text-sm tabular-nums max-h-56 w-14"
                >
                  <template #item="{ value }">
                    <TimePicker.ColumnItem
                      :value="value"
                      class="border-0 bg-transparent box-border flex h-8 flex-none cursor-pointer items-center justify-center rounded-md px-3 whitespace-nowrap select-none hover:not-disabled:not-aria-selected:bg-neutral-100 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-neutral-950 disabled:cursor-default disabled:opacity-40 aria-selected:bg-neutral-950 aria-selected:text-white aria-selected:focus-visible:outline-white dark:hover:not-disabled:not-aria-selected:bg-neutral-800 dark:focus-visible:outline-white dark:aria-selected:bg-white dark:aria-selected:text-neutral-950 dark:aria-selected:focus-visible:outline-neutral-950"
                    />
                  </template>
                </TimePicker.Column>
              </div>
            </TimePicker.Popup>
          </Transition>
        </TimePicker.Positioner>
      </Popover.Portal>
    </TimePicker.Root>
  </div>
</template>

Clock ​

TimePicker.Clock holds the parts of Time Clock. The granularity of the picker sets its last view, and a commit of that view closes the popup.

vue
<script setup lang="ts">
import { useId } from 'vue';
import { TimeClock } from '@vase-ui/vue/time-clock';
import { TimeField } from '@vase-ui/vue/time-field';
import { TimePicker } from '@vase-ui/vue/time-picker';
import { Popover } from '@vase-ui/vue/popover';
import styles from '../../_index.module.css';

const id = useId();
const defaultValue = Temporal.PlainTime.from('10:30');

const popupHiddenClass = styles.PopupHidden;
</script>

<template>
  <div :class="styles.Field">
    <label :for="id" :class="styles.Label">Reminder time</label>
    <TimePicker.Root :default-value="defaultValue" locale="en-US" :hour-cycle="12">
      <div :class="styles.Control">
        <TimePicker.Field :id="id" :class="styles.Group">
          <TimeField.Input :class="styles.Input">
            <template #segment="{ segment }">
              <TimeField.Segment
                v-if="segment.editable"
                :segment="segment"
                :class="styles.Segment"
              />
              <TimeField.Literal v-else :segment="segment" :class="styles.Literal" />
            </template>
          </TimeField.Input>
        </TimePicker.Field>
        <TimePicker.Trigger aria-label="Choose time" :class="styles.Trigger">
          <svg
            aria-hidden="true"
            width="16"
            height="16"
            viewBox="0 0 16 16"
            fill="none"
            stroke="currentColor"
            stroke-linecap="square"
          >
            <circle cx="8" cy="8" r="5.5" />
            <path d="M8 4.5V8l2.5 1.5" />
          </svg>
        </TimePicker.Trigger>
      </div>
      <Popover.Portal>
        <TimePicker.Positioner :side-offset="4">
          <Transition :enter-from-class="popupHiddenClass" :leave-to-class="popupHiddenClass">
            <TimePicker.Popup aria-label="Choose a reminder time" :class="styles.Popup">
              <TimePicker.Clock :class="styles.Clock">
                <div :class="styles.Header">
                  <TimeClock.ViewTrigger view="hour" :class="styles.ViewTrigger" />
                  <span aria-hidden="true" :class="styles.Separator">:</span>
                  <TimeClock.ViewTrigger view="minute" :class="styles.ViewTrigger" />
                  <TimeClock.DayPeriod value="am" :class="styles.DayPeriod" />
                  <TimeClock.DayPeriod value="pm" :class="styles.DayPeriod" />
                </div>
                <TimeClock.Face :class="styles.Face">
                  <TimeClock.Hand :class="styles.Hand" />
                  <template #number="{ number }">
                    <TimeClock.Number :number="number" :class="styles.Number" />
                  </template>
                </TimeClock.Face>
              </TimePicker.Clock>
            </TimePicker.Popup>
          </Transition>
        </TimePicker.Positioner>
      </Popover.Portal>
    </TimePicker.Root>
  </div>
</template>
css
.Field {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: 0.25rem;
}

.Label {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 700;
  color: oklch(14.5% 0 0deg);

  @media (prefers-color-scheme: dark) {
    color: white;
  }
}

.Control {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  height: 2rem;
  border: 1px solid oklch(14.5% 0 0deg);
  background-color: white;
  color: oklch(14.5% 0 0deg);

  @media (prefers-color-scheme: dark) {
    border-color: white;
    background-color: oklch(14.5% 0 0deg);
    color: white;
  }

  &:focus-within {
    outline: 2px solid oklch(14.5% 0 0deg);
    outline-offset: -1px;

    @media (prefers-color-scheme: dark) {
      outline-color: white;
    }
  }
}

.Group {
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
}

.Input {
  display: flex;
  align-items: center;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;

  @media (any-pointer: coarse) {
    font-size: 1rem;
    line-height: 1.5rem;
  }
}

.Segment {
  /* The box follows the text. A browser with no `field-sizing` keeps the width of `size`. */
  field-sizing: content;
  margin: 0;
  padding: 0 0.125rem;
  border: 0;
  border-radius: 0;
  outline: 0;
  font: inherit;
  text-align: center;
  caret-color: transparent;
  background-color: transparent;
  color: inherit;

  &::placeholder {
    color: oklch(55.6% 0 0deg);

    @media (prefers-color-scheme: dark) {
      color: oklch(70.8% 0 0deg);
    }
  }

  &:focus {
    background-color: oklch(14.5% 0 0deg);
    color: white;

    @media (prefers-color-scheme: dark) {
      background-color: white;
      color: oklch(14.5% 0 0deg);
    }

    &::placeholder {
      color: oklch(70.8% 0 0deg);

      @media (prefers-color-scheme: dark) {
        color: oklch(43.9% 0 0deg);
      }
    }
  }
}

.Literal {
  color: oklch(43.9% 0 0deg);
  white-space: pre;

  @media (prefers-color-scheme: dark) {
    color: oklch(70.8% 0 0deg);
  }
}

.Trigger {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.875rem;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid oklch(14.5% 0 0deg);
  border-radius: 0;
  font: inherit;
  color: inherit;
  background-color: transparent;
  user-select: none;

  @media (prefers-color-scheme: dark) {
    border-left-color: white;
  }

  @media (hover: hover) {
    &:hover:not(:disabled) {
      background-color: oklch(97% 0 0deg);

      @media (prefers-color-scheme: dark) {
        background-color: oklch(26.9% 0 0deg);
      }
    }
  }

  &[aria-expanded='true'] {
    background-color: oklch(97% 0 0deg);

    @media (prefers-color-scheme: dark) {
      background-color: oklch(26.9% 0 0deg);
    }
  }

  &:disabled {
    color: oklch(55.6% 0 0deg);

    @media (prefers-color-scheme: dark) {
      color: oklch(70.8% 0 0deg);
    }
  }

  &:focus-visible {
    outline: 2px solid oklch(14.5% 0 0deg);
    outline-offset: -1px;

    @media (prefers-color-scheme: dark) {
      outline-color: white;
    }
  }
}

.Popup {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem;
  outline: none;
  border: 1px solid oklch(14.5% 0 0deg);
  background-color: white;
  color: oklch(14.5% 0 0deg);
  box-shadow: 0.25rem 0.25rem 0 rgb(0 0 0 / 12%);
  transform-origin: var(--transform-origin);
  transition:
    transform 100ms ease-out,
    opacity 100ms ease-out;

  @media (prefers-color-scheme: dark) {
    border-color: white;
    background-color: oklch(14.5% 0 0deg);
    color: white;
    box-shadow: none;
  }
}

/* The enter-from and leave-to class of the `<Transition>` around the popup. */
.PopupHidden {
  opacity: 0;
  transform: scale(0.98);
}

.List,
.Column {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  max-height: 14rem;
  overflow-y: auto;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.List {
  width: 8rem;
}

.Columns {
  display: flex;
  gap: 0.5rem;
}

.Column {
  width: 3.5rem;
}

.Item {
  box-sizing: border-box;
  margin: 0;
  border: 0;
  font: inherit;
  color: inherit;
  background-color: transparent;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  height: 2rem;
  padding: 0 0.75rem;
  border-radius: 0.375rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;

  &:hover:not([aria-selected='true']):not(:disabled) {
    background-color: oklch(97% 0 0deg);

    @media (prefers-color-scheme: dark) {
      background-color: oklch(26.9% 0 0deg);
    }
  }

  &[aria-selected='true'] {
    background-color: oklch(14.5% 0 0deg);
    color: white;

    @media (prefers-color-scheme: dark) {
      background-color: white;
      color: oklch(14.5% 0 0deg);
    }
  }

  &:disabled {
    opacity: 0.4;
    cursor: default;
  }

  &:focus-visible {
    outline: 2px solid oklch(14.5% 0 0deg);
    outline-offset: -2px;

    @media (prefers-color-scheme: dark) {
      outline-color: white;
    }
  }

  &[aria-selected='true']:focus-visible {
    outline-color: white;

    @media (prefers-color-scheme: dark) {
      outline-color: oklch(14.5% 0 0deg);
    }
  }
}

.Clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: oklch(14.5% 0 0deg);

  @media (prefers-color-scheme: dark) {
    color: white;
  }
}

.Header {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.Separator {
  font-size: 1.25rem;
  font-weight: 700;
}

.ViewTrigger,
.DayPeriod {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  margin: 0;
  padding: 0 0.5rem;
  border: 1px solid oklch(14.5% 0 0deg);
  border-radius: 0;
  background-color: white;
  color: oklch(14.5% 0 0deg);
  font-family: inherit;
  font-size: 1.25rem;
  line-height: 1.5rem;
  font-variant-numeric: tabular-nums;
  -webkit-user-select: none;
  user-select: none;

  @media (prefers-color-scheme: dark) {
    border: 1px solid white;
    background-color: oklch(14.5% 0 0deg);
    color: white;
  }

  @media (hover: hover) {
    &:hover:not(:disabled, [aria-pressed='true']) {
      background-color: oklch(97% 0 0deg);

      @media (prefers-color-scheme: dark) {
        background-color: oklch(26.9% 0 0deg);
      }
    }
  }

  &:focus-visible {
    z-index: 1;
    outline: 2px solid oklch(14.5% 0 0deg);
    outline-offset: 2px;

    @media (prefers-color-scheme: dark) {
      outline-color: white;
    }
  }

  &[aria-pressed='true'] {
    background-color: oklch(14.5% 0 0deg);
    color: white;

    @media (prefers-color-scheme: dark) {
      background-color: white;
      color: oklch(14.5% 0 0deg);
    }
  }

  &:disabled {
    color: oklch(55.6% 0 0deg);
    border-color: oklch(55.6% 0 0deg);

    @media (prefers-color-scheme: dark) {
      color: oklch(70.8% 0 0deg);
      border-color: oklch(70.8% 0 0deg);
    }
  }
}

.DayPeriod {
  font-size: 0.875rem;
}

/*
 * The face is the containing block of the hand, the numbers and the range input of the part. The
 * parts write the angle and the radius as variables and set no position, so each rule below places
 * them.
 */
.Face {
  --radius: 5.5rem;

  position: relative;
  box-sizing: border-box;
  width: 14rem;
  height: 14rem;
  border: 1px solid oklch(14.5% 0 0deg);
  border-radius: 50%;
  background-color: oklch(97% 0 0deg);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;

  @media (prefers-color-scheme: dark) {
    border: 1px solid white;
    background-color: oklch(26.9% 0 0deg);
  }

  &:has(:focus-visible) {
    outline: 2px solid oklch(14.5% 0 0deg);
    outline-offset: 2px;

    @media (prefers-color-scheme: dark) {
      outline-color: white;
    }
  }

  &[data-disabled],
  &[data-readonly] {
    cursor: default;
  }
}

.Hand {
  position: absolute;
  bottom: 50%;
  left: 50%;
  width: 2px;
  height: calc(var(--time-clock-hand-length) * var(--radius));
  background-color: oklch(14.5% 0 0deg);
  translate: -50% 0;
  transform-origin: 50% 100%;
  transform: rotate(var(--time-clock-hand-angle));
  pointer-events: none;

  @media (prefers-color-scheme: dark) {
    background-color: white;
  }

  /* A time between two numbers has a tip and no selected number under it. */
  &[data-between-numbers]::after {
    content: '';
    position: absolute;
    top: -0.25rem;
    left: 50%;
    width: 0.5rem;
    height: 0.5rem;
    translate: -50% 0;
    border-radius: 50%;
    background-color: oklch(14.5% 0 0deg);

    @media (prefers-color-scheme: dark) {
      background-color: white;
    }
  }
}

.Number {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin: -1rem 0 0 -1rem;
  border-radius: 50%;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  pointer-events: none;

  /* Turn to the angle, move out by the radius, and turn back so that the digits stay upright. */
  transform: rotate(var(--time-clock-number-angle))
    translateY(calc(var(--time-clock-number-radius) * var(--radius) * -1))
    rotate(calc(var(--time-clock-number-angle) * -1));

  &[data-inner] {
    width: 1.75rem;
    height: 1.75rem;
    margin: -0.875rem 0 0 -0.875rem;
    font-size: 0.75rem;
  }

  &[data-selected] {
    background-color: oklch(14.5% 0 0deg);
    color: white;

    @media (prefers-color-scheme: dark) {
      background-color: white;
      color: oklch(14.5% 0 0deg);
    }
  }

  &[data-disabled] {
    color: oklch(43.9% 0 0deg);

    @media (prefers-color-scheme: dark) {
      color: oklch(70.8% 0 0deg);
    }
  }
}
vue
<script setup lang="ts">
import { useId } from 'vue';
import { TimeClock } from '@vase-ui/vue/time-clock';
import { TimeField } from '@vase-ui/vue/time-field';
import { TimePicker } from '@vase-ui/vue/time-picker';
import { Popover } from '@vase-ui/vue/popover';

const id = useId();
const defaultValue = Temporal.PlainTime.from('10:30');

const buttonClass =
  'flex h-10 min-w-10 items-center justify-center border border-neutral-950 bg-white px-2 leading-6 text-neutral-950 tabular-nums select-none focus-visible:z-1 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950 disabled:border-neutral-500 disabled:text-neutral-500 dark:border-white dark:bg-neutral-950 dark:text-white dark:focus-visible:outline-white dark:disabled:border-neutral-400 dark:disabled:text-neutral-400';
const triggerClass =
  'text-xl hover:not-disabled:not-aria-pressed:bg-neutral-100 aria-pressed:bg-neutral-950 aria-pressed:not-disabled:text-white dark:hover:not-disabled:not-aria-pressed:bg-neutral-800 dark:aria-pressed:bg-white dark:aria-pressed:not-disabled:text-neutral-950';
const dayPeriodClass =
  'text-sm hover:not-disabled:not-aria-pressed:bg-neutral-100 aria-pressed:bg-neutral-950 aria-pressed:not-disabled:text-white dark:hover:not-disabled:not-aria-pressed:bg-neutral-800 dark:aria-pressed:bg-white dark:aria-pressed:not-disabled:text-neutral-950';

const popupHiddenClass = 'scale-[0.98] opacity-0';
</script>

<template>
  <div class="flex flex-col items-start gap-1">
    <label :for="id" class="text-sm font-bold text-neutral-950 dark:text-white"
      >Reminder time</label
    >
    <TimePicker.Root :default-value="defaultValue" locale="en-US" :hour-cycle="12">
      <div
        class="box-border flex h-8 items-center border border-neutral-950 bg-white text-neutral-950 focus-within:outline-2 focus-within:-outline-offset-1 focus-within:outline-neutral-950 dark:border-white dark:bg-neutral-950 dark:text-white dark:focus-within:outline-white"
      >
        <TimePicker.Field :id="id" class="flex items-center px-2">
          <TimeField.Input
            class="flex items-center text-sm font-normal tabular-nums any-pointer-coarse:text-base"
          >
            <template #segment="{ segment }">
              <TimeField.Segment
                v-if="segment.editable"
                :segment="segment"
                class="field-sizing-content px-0.5 text-center caret-transparent outline-0 placeholder:text-neutral-500 focus:bg-neutral-950 focus:text-white focus:placeholder:text-neutral-400 dark:placeholder:text-neutral-400 dark:focus:bg-white dark:focus:text-neutral-950 dark:focus:placeholder:text-neutral-600"
              />
              <TimeField.Literal
                v-else
                :segment="segment"
                class="whitespace-pre text-neutral-600 dark:text-neutral-400"
              />
            </template>
          </TimeField.Input>
        </TimePicker.Field>
        <TimePicker.Trigger
          aria-label="Choose time"
          class="box-border flex h-full w-[1.875rem] items-center justify-center border-0 border-l border-neutral-950 bg-transparent p-0 select-none hover:not-disabled:bg-neutral-100 disabled:text-neutral-500 aria-expanded:bg-neutral-100 focus-visible:outline-2 focus-visible:-outline-offset-1 focus-visible:outline-neutral-950 dark:border-white dark:hover:not-disabled:bg-neutral-800 dark:disabled:text-neutral-400 dark:aria-expanded:bg-neutral-800 dark:focus-visible:outline-white"
        >
          <svg
            aria-hidden="true"
            width="16"
            height="16"
            viewBox="0 0 16 16"
            fill="none"
            stroke="currentColor"
            stroke-linecap="square"
          >
            <circle cx="8" cy="8" r="5.5" />
            <path d="M8 4.5V8l2.5 1.5" />
          </svg>
        </TimePicker.Trigger>
      </div>
      <Popover.Portal>
        <TimePicker.Positioner :side-offset="4">
          <Transition :enter-from-class="popupHiddenClass" :leave-to-class="popupHiddenClass">
            <TimePicker.Popup
              aria-label="Choose a reminder time"
              class="box-border flex origin-[var(--transform-origin)] flex-col gap-3 border border-neutral-950 bg-white p-3 text-neutral-950 shadow-[0.25rem_0.25rem_0] shadow-black/12 outline-none transition-[scale,opacity] duration-100 ease-out dark:border-white dark:bg-neutral-950 dark:text-white dark:shadow-none"
            >
              <TimePicker.Clock
                class="flex flex-col items-center gap-3 text-neutral-950 dark:text-white"
              >
                <div class="flex items-center gap-1">
                  <TimeClock.ViewTrigger view="hour" :class="[buttonClass, triggerClass]" />
                  <span aria-hidden="true" class="text-xl font-bold">:</span>
                  <TimeClock.ViewTrigger view="minute" :class="[buttonClass, triggerClass]" />
                  <TimeClock.DayPeriod value="am" :class="[buttonClass, dayPeriodClass]" />
                  <TimeClock.DayPeriod value="pm" :class="[buttonClass, dayPeriodClass]" />
                </div>
                <TimeClock.Face
                  class="relative size-56 cursor-pointer rounded-full border border-neutral-950 bg-neutral-100 select-none [--radius:5.5rem] has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-neutral-950 data-disabled:cursor-default data-readonly:cursor-default dark:border-white dark:bg-neutral-800 dark:has-focus-visible:outline-white"
                >
                  <TimeClock.Hand
                    class="pointer-events-none absolute bottom-1/2 left-1/2 h-[calc(var(--time-clock-hand-length)*var(--radius))] w-0.5 origin-bottom -translate-x-1/2 rotate-(--time-clock-hand-angle) bg-neutral-950 data-between-numbers:after:absolute data-between-numbers:after:-top-1 data-between-numbers:after:left-1/2 data-between-numbers:after:size-2 data-between-numbers:after:-translate-x-1/2 data-between-numbers:after:rounded-full data-between-numbers:after:bg-neutral-950 data-between-numbers:after:content-[''] dark:bg-white dark:data-between-numbers:after:bg-white"
                  />
                  <template #number="{ number }">
                    <TimeClock.Number
                      :number="number"
                      class="pointer-events-none absolute top-1/2 left-1/2 -mt-4 -ml-4 flex size-8 items-center justify-center rounded-full text-sm tabular-nums transform-[rotate(var(--time-clock-number-angle))_translateY(calc(var(--time-clock-number-radius)*var(--radius)*-1))_rotate(calc(var(--time-clock-number-angle)*-1))] data-disabled:text-neutral-600 data-inner:-mt-3.5 data-inner:-ml-3.5 data-inner:size-7 data-inner:text-xs data-selected:bg-neutral-950 data-selected:not-data-disabled:text-white dark:data-disabled:text-neutral-400 dark:data-selected:bg-white dark:data-selected:not-data-disabled:text-neutral-950"
                    />
                  </template>
                </TimeClock.Face>
              </TimePicker.Clock>
            </TimePicker.Popup>
          </Transition>
        </TimePicker.Positioner>
      </Popover.Portal>
    </TimePicker.Root>
  </div>
</template>

Show the time in the trigger ​

The text of the slots of TimePicker.Trigger is the time in the locale, or undefined with no value. Show it in the trigger as in the sample of Date Picker. Give the element of the text data-allow-mismatch="text", because a server can have other Intl data than the browser.

Keyboard ​

KeyAction
Alt+Down in the fieldOpens the popup, and gives the focus to the first list, column or clock in it.
Enter, SpaceOn the trigger, opens the popup. On an item, selects it, and closes the popup when closeOnSelect allows it.
Down, UpIn a list or a column, moves the focus to the next or the previous item. The last item goes to the first. A disabled item gets no focus.
Home, EndIn a list or a column, moves the focus to the first or the last item.
TabMoves the focus from one column to the next, and then through the popup in the order of the page.
EscapeCloses the popup and gives the focus back to the trigger. The value stays.
The keys of Time Field and Time ClockDo the same actions in the field and on the clock.

API reference ​

TimePicker.Root ​

Groups the parts of the picker and holds its value. It renders Popover.Root, so each part of Popover, such as Popover.Portal and Popover.Close, works in it. Renders no element.

Props

PropTypeDefaultDescription
closeOnSelectboolean | undefinedA pick closes the popup. With no prop, a press on an item of TimePicker.List and the commit of the last view of TimePicker.Clock close it, and a press in TimePicker.Column does not. In a wrapper that declares this prop, give it the default undefined.
defaultOpenboolean | undefinedfalseThe popup is open at the mount of an uncontrolled picker.
defaultValueValue | null | undefinedThe value of a picker with no modelValue, at the mount and at a native reset of the form.
disabledboolean | undefinedfalseThe user cannot change the value or open the popup.
forceLeadingZerosboolean | undefinedfalseThe hour shows a leading zero. A 24-hour cycle always has one.
formstring | undefinedThe id of the form of the form input, for a picker outside that form.
granularityTimeFieldRootGranularity | undefined'minute'The last unit that the field shows and that the clock selects.
hideTimeZoneboolean | undefinedfalseThe field shows no time zone name for a Temporal.ZonedDateTime.
hourCycle12 | 24 | undefinedThe hour cycle. The default is the hour cycle of the locale.
localeIntl.LocalesArgumentThe locale of each text. The default is the locale of the nearest LocaleProvider, else en-US.
maxTemporal.PlainTime | undefinedThe latest time. The list ends at it, the columns and the clock disable a later time, and a later time makes the field invalid.
minTemporal.PlainTime | undefinedThe earliest time. The list starts at it, the columns and the clock disable an earlier time, and an earlier time makes the field invalid.
modalboolean | "trap-focus" | undefinedfalseThe modal state of the open popup, as for Popover.Root.
modelValueValue | null | undefinedThe value: a Temporal.PlainTime, PlainDateTime or ZonedDateTime, or null for no value. A new value has the kind, the date and the zone of the value, else of defaultValue, else of the last value.
namestring | undefinedThe name of the form input. The name of a Field wins.
openboolean | undefinedThe popup is open. v-model:open binds it.
readonlyboolean | undefinedfalseThe user cannot change the value or open the popup. The field stays in the tab order and in the form data.
referenceDateValue | undefinedGives the kind, the date and the time zone of a first value. With no value, the clock shows its time, and a column sets one unit of it. With none, that time is midnight.
requiredboolean | undefinedfalseThe user must give a value before a submit.

Slots

SlotSlot propsDescription
defaultThe content of the part.

Events

EventArgumentsDescription
valueChange[value: Value | null, details: TimePickerRootChangeEventDetails]The user changes the value. The value is null while a segment is empty. details.cancel() keeps the value as it was.
update:modelValue[value: Value | null]Comes after valueChange, unless a listener cancels the change. v-model uses it. A reset of the form and clear() of a field emit it with no valueChange.
openChange[open: boolean, details: TimePickerRootOpenChangeEventDetails]The popup opens or closes. details.cancel() keeps it as it was.
update:open[open: boolean]Comes after openChange, unless a listener cancels the change. v-model:open uses it.

Exposed

MemberTypeDescription
close() => void | undefinedCloses the popup with the reason 'imperative-action'.

TimePicker.Field ​

The field of the picker: TimeField.Root with the value of the picker. It takes the other props of TimeField.Root, such as id and step, and it has the selectors of that part. Its form input gives the value to a form. Alt+ArrowDown in it opens the popup. Renders a <div> element with a hidden form <input> element in it.

Slots

SlotSlot propsDescription
default
state: TimePickerFieldState
The content of the part.

Exposed

MemberTypeDescription
elementHTMLElement | nullThe element of the part, or null while it is not mounted.
inputElementHTMLInputElement | nullThe input that gives the value to a form.
clear() => voidEmpties each segment. update:modelValue follows when the picker had a value.

TimePicker.Trigger ​

A button that opens the popup: Popover.Trigger of the picker. The text of its slots is the time in the locale, or undefined with no value. Renders a <button> element.

Props

PropTypeDefaultDescription
disabledboolean | undefinedfalseThe user cannot press the trigger. A disabled or read-only picker also disables it.

Slots

SlotSlot propsDescription
default
state: TimePickerTriggerState
text: string | undefined
The content of the part.
element
props: Record<string, unknown>
elementRef: (target: unknown) => void
state: TimePickerTriggerState
text: string | undefined
Renders your element in place of the element of the part. Bind props with v-bind and elementRef with :ref.

Exposed

MemberTypeDescription
elementHTMLElement | nullThe element of the part, or null while it is not mounted.

Selectors

SelectorDescription
[aria-expanded="true"]The popup is open.
[data-pressed]The popup is open, and a press on the trigger or Alt+ArrowDown in the field opened it.
:disabledThe trigger is a native button, and the trigger or the picker is disabled or read-only.
[aria-disabled="true"]The trigger is another element, and the trigger or the picker is disabled or read-only.

TimePicker.Positioner ​

Places the popup at the field: Popover.Positioner of the picker. Renders a <div> element.

Props

PropTypeDefaultDescription
alignAlign | undefined'start'The alignment of the popup on the side of the anchor.
anchorAnchor | (() => Anchor)The anchor of the popup. The default is the first field of the picker, else the trigger.

Slots

SlotSlot propsDescription
default
state: TimePickerPositionerState
The content of the part.
element
props: Record<string, unknown>
elementRef: (target: unknown) => void
state: TimePickerPositionerState
Renders your element in place of the element of the part. Bind props with v-bind and elementRef with :ref.

Exposed

MemberTypeDescription
elementHTMLElement | nullThe element of the part, or null while it is not mounted.

Selectors

SelectorDescription
[data-side]The side of the anchor that the popup is on: top, bottom, left, right, inline-start or inline-end.
[data-align]The alignment of the popup on that side: start, center or end.
[data-anchor-hidden]The anchor is out of the view.

CSS variables

VariableDescription
--anchor-widthThe width of the anchor.
--anchor-heightThe height of the anchor.
--available-widthThe width that the popup has before it goes out of its collision boundary.
--available-heightThe height that the popup has before it goes out of its collision boundary.
--transform-originThe point that the popup grows from, for the transform-origin of the popup. It is on the edge of the anchor, at the aligned edge of the popup or at the center of the anchor.

TimePicker.Popup ​

The container of the list, the columns or the clock: Popover.Popup of the picker. It gives the focus to the first of them at each open. Renders a <div> element.

Props

PropTypeDefaultDescription
initialFocusFocusTarget | undefinedThe element that gets the focus at the open. The default is the first list, column or clock in the popup, else the default of Popover.Popup. true, null and a function that gives one of them ask for that default. false moves no focus.

Slots

SlotSlot propsDescription
default
state: TimePickerPopupState
The content of the part.
element
props: Record<string, unknown>
elementRef: (target: unknown) => void
state: TimePickerPopupState
Renders your element in place of the element of the part. Bind props with v-bind and elementRef with :ref.

Exposed

MemberTypeDescription
elementHTMLElement | nullThe element of the part, or null while it is not mounted.

Selectors

SelectorDescription
[data-side]The side of the anchor that the popup is on: top, bottom, left, right, inline-start or inline-end.
[data-align]The alignment of the popup on that side: start, center or end.
[data-instant]The popup changes with no animation: click after a key opened it, dismiss after Escape closed it, or focus after the focus left it.
[hidden]The popup is closed, and keepMounted of Popover.Portal keeps it in the DOM.

TimePicker.List ​

A list of times, by a step of minutes. Renders a <div> element.

Props

PropTypeDefaultDescription
stepnumber | undefined30The minutes between two times. The list goes from min of the picker, else midnight, to max, else the end of the day.
askeyof HTMLElementTagNameMap | Component | GenericComponent | undefinedA tag or a component that the part renders in place of its own element, with the same attributes and content. The element slot wins over it.

Slots

SlotSlot propsDescription
item
time: Temporal.PlainTime
index: number
One time of the list. With no slot, the list renders a TimePicker.Item for each time.
element
props: Record<string, unknown>
elementRef: (target: unknown) => void
state: TimePickerListState
times: Temporal.PlainTime[]
Renders your element in place of the element of the part. Bind props with v-bind and elementRef with :ref.

Exposed

MemberTypeDescription
elementHTMLElement | nullThe element of the part, or null while it is not mounted.

Selectors

SelectorDescription
[aria-disabled="true"]The picker is disabled.
[aria-readonly="true"]The picker is read-only.

TimePicker.Item ​

A time of TimePicker.List. A press gives the time to the picker. Renders a <button> element.

Props

PropTypeDefaultDescription
disabledboolean | undefinedfalseThe user cannot press the item.
timeTemporal.PlainTimeRequiredThe time that the item gives. The item slot of TimePicker.List gives it.
askeyof HTMLElementTagNameMap | Component | GenericComponent | undefinedA tag or a component that the part renders in place of its own element, with the same attributes and content. The element slot wins over it.

Slots

SlotSlot propsDescription
default
state: TimePickerItemState
text: string
The content of the part.
element
props: Record<string, unknown>
elementRef: (target: unknown) => void
state: TimePickerItemState
text: string
Renders your element in place of the element of the part. Bind props with v-bind and elementRef with :ref.

Exposed

MemberTypeDescription
elementHTMLElement | nullThe element of the part, or null while it is not mounted.

Selectors

SelectorDescription
[aria-selected="true"]The time of the item is the time of the value.
:disabledThe item is a native button, and the item or the picker is disabled.
[aria-disabled="true"]The item is another element, and the item or the picker is disabled.

TimePicker.Column ​

A list of the values of one unit: the hours, the minutes, the seconds or the day periods. Its name is the name of its unit in the locale. Renders a <div> element.

Props

PropTypeDefaultDescription
stepnumber | undefined1The step of the hours, the minutes or the seconds.
unitTimePickerColumnUnitRequiredThe unit that the column sets. A column of day periods renders nothing in a 24-hour cycle.
askeyof HTMLElementTagNameMap | Component | GenericComponent | undefinedA tag or a component that the part renders in place of its own element, with the same attributes and content. The element slot wins over it.

Slots

SlotSlot propsDescription
item
value: TimePickerColumnValue
index: number
One value of the column. With no slot, the column renders a TimePicker.ColumnItem for each.
element
props: Record<string, unknown>
elementRef: (target: unknown) => void
state: TimePickerColumnState
values: TimePickerColumnValue[]
Renders your element in place of the element of the part. Bind props with v-bind and elementRef with :ref.

Exposed

MemberTypeDescription
elementHTMLElement | nullThe element of the part, or null while it is not mounted.

Selectors

SelectorDescription
[aria-disabled="true"]The picker is disabled.
[aria-readonly="true"]The picker is read-only.

TimePicker.ColumnItem ​

A value of TimePicker.Column. A press sets the unit of the time, keeps the other units, and moves the time into min and max. Renders a <button> element.

Props

PropTypeDefaultDescription
disabledboolean | undefinedfalseThe user cannot press the item. min and max of the picker also disable an item.
valueTimePickerColumnValueRequiredThe value that the item sets: an hour, a minute or a second, or 'am' or 'pm'. The item slot of TimePicker.Column gives it. An hour of a 12-hour cycle goes from 1 to 12.
askeyof HTMLElementTagNameMap | Component | GenericComponent | undefinedA tag or a component that the part renders in place of its own element, with the same attributes and content. The element slot wins over it.

Slots

SlotSlot propsDescription
default
state: TimePickerColumnItemState
text: string
The content of the part.
element
props: Record<string, unknown>
elementRef: (target: unknown) => void
state: TimePickerColumnItemState
text: string
Renders your element in place of the element of the part. Bind props with v-bind and elementRef with :ref.

Exposed

MemberTypeDescription
elementHTMLElement | nullThe element of the part, or null while it is not mounted.

Selectors

SelectorDescription
[aria-selected="true"]The value of the item is the unit of the time of the value.
:disabledThe item is a native button, and the item or the picker is disabled, or its value has no time between min and max.
[aria-disabled="true"]The item is another element, and the item or the picker is disabled, or its value has no time between min and max.

TimePicker.Clock ​

The clock of the picker: TimeClock.Root with the value of the picker. It takes the other props and events of TimeClock.Root, such as minuteStep and valueCommitted, and it has the selectors of that part. The commit of the last view closes the popup when closeOnSelect of the root allows it. Renders a <div> element.

Props

PropTypeDefaultDescription
defaultViewTimeClockView | undefined'hour'The view of an uncontrolled clock at each open of the popup.
viewTimeClockView | undefinedThe unit that the face shows. v-model:view binds it.

Slots

SlotSlot propsDescription
default
state: TimePickerClockState
The content of the part.
element
props: Record<string, unknown>
elementRef: (target: unknown) => void
state: TimePickerClockState
Renders your element in place of the element of the part. Bind props with v-bind and elementRef with :ref.

Events

EventArgumentsDescription
update:view[view: TimeClockView]Comes after viewChange of the clock, unless a listener cancels it. v-model:view uses it.

Exposed

MemberTypeDescription
elementHTMLElement | nullThe element of the part, or null while it is not mounted.

TimePicker.Root.ChangeEventReason ​

The reason of valueChange: item-press comes from the list and the columns, drag from the clock face, and the other reasons from the field or the clock.

'input-change' | 'input-clear' | 'input-paste' | 'keyboard' | 'clear-press' | 'drag' | 'item-press'

TimePicker.Root.OpenChangeEventReason ​

The reason of openChange: Alt+Down in the field gives trigger-press, and a pick that closes the popup gives imperative-action.

'trigger-hover' | 'trigger-focus' | 'trigger-press' | 'outside-press' | 'escape-key' | 'close-press' | 'focus-out' | 'imperative-action' | 'none'

TimePicker.Column.Unit ​

The units that the unit prop of TimePicker.Column takes.

'hour' | 'minute' | 'second' | 'dayPeriod'

Differences from Base UI ​

Base UI has no Time Picker. A person types a time in a field, or picks it from a list, from columns or on a clock face in a popup. The picker gives one Temporal value to a form.

The handbook gives the differences that all components share: Styling, Animation, Composition, Customization, Forms and TypeScript.