Date Picker
A field to type a date in, and a calendar in a popup to pick one.
<script setup lang="ts">
import { useId } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import { DateField } from '@vase-ui/vue/date-field';
import { DatePicker } from '@vase-ui/vue/date-picker';
import { Popover } from '@vase-ui/vue/popover';
import styles from '../../_index.module.css';
const id = useId();
const defaultValue = Temporal.PlainDate.from('2026-11-18');
const popupHiddenClass = styles.PopupHidden;
</script>
<template>
<div :class="styles.Field">
<label :for="id" :class="styles.Label">Departure date</label>
<DatePicker.Root :default-value="defaultValue" locale="en-US">
<div :class="styles.Control">
<DatePicker.Field :id="id" :class="styles.Group">
<DateField.Input :class="styles.Input">
<template #segment="{ segment }">
<DateField.Segment
v-if="segment.editable"
:segment="segment"
:class="styles.Segment"
/>
<DateField.Literal v-else :segment="segment" :class="styles.Literal" />
</template>
</DateField.Input>
</DatePicker.Field>
<DatePicker.Trigger aria-label="Choose date" :class="styles.Trigger">
<svg
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-linecap="square"
>
<rect x="2.5" y="3.5" width="11" height="10" />
<path d="M2.5 6.5h11M5.5 2v3M10.5 2v3" />
</svg>
</DatePicker.Trigger>
</div>
<Popover.Portal>
<DatePicker.Positioner :side-offset="4">
<Transition :enter-from-class="popupHiddenClass" :leave-to-class="popupHiddenClass">
<DatePicker.Popup aria-label="Choose a departure date" :class="styles.Popup">
<DatePicker.Calendar :class="styles.Calendar">
<div :class="styles.Nav">
<Calendar.PreviousButton :class="styles.Button">‹</Calendar.PreviousButton>
<Calendar.NextButton :class="styles.Button">›</Calendar.NextButton>
</div>
<Calendar.Months>
<template #month="{ month }">
<Calendar.Month :month="month">
<Calendar.Caption :class="styles.Caption" />
<Calendar.Grid :class="styles.Grid">
<Calendar.GridHeader>
<Calendar.GridHeaderRow>
<template #weekday="{ weekday }">
<Calendar.Weekday :weekday="weekday" :class="styles.Weekday" />
</template>
</Calendar.GridHeaderRow>
</Calendar.GridHeader>
<Calendar.GridBody>
<template #week="{ week }">
<Calendar.Week :week="week">
<template #day="{ day }">
<Calendar.Day :day="day" :class="styles.Day">
<Calendar.DayButton :class="styles.DayButton" />
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</DatePicker.Calendar>
</DatePicker.Popup>
</Transition>
</DatePicker.Positioner>
</Popover.Portal>
</DatePicker.Root>
</div>
</template>.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;
}
}
.Row {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.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);
}
.Calendar {
position: relative;
box-sizing: border-box;
width: 17rem;
font-size: 0.875rem;
line-height: 1.25rem;
}
.Nav {
position: absolute;
top: 0;
right: 0;
display: flex;
gap: 0.25rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Button {
width: 2rem;
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
&:hover:not(:disabled, [aria-disabled='true']) {
background-color: oklch(97% 0 0deg);
@media (prefers-color-scheme: dark) {
background-color: oklch(26.9% 0 0deg);
}
}
&:is(:disabled, [aria-disabled='true']) {
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;
}
}
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday {
padding: 0.25rem 0;
font-size: 0.75rem;
font-weight: 500;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.MonthCell {
box-sizing: border-box;
margin: 0;
padding: 0;
border: 1px solid transparent;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
&:hover:not([data-selected], [aria-selected='true'], :disabled) {
background-color: oklch(97% 0 0deg);
@media (prefers-color-scheme: dark) {
background-color: oklch(26.9% 0 0deg);
}
}
&[aria-current='date'] {
border-color: oklch(70.8% 0 0deg);
}
&:is([data-selected], [aria-selected='true']) {
color: white;
background-color: oklch(14.5% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(14.5% 0 0deg);
background-color: white;
}
}
&[data-outside-month]:not([data-selected]) {
color: oklch(55.6% 0 0deg);
}
&:disabled {
cursor: default;
opacity: 0.4;
}
&:focus-visible {
outline: 2px solid oklch(14.5% 0 0deg);
outline-offset: 2px;
@media (prefers-color-scheme: dark) {
outline-color: white;
}
}
}
.DayButton {
width: 2.25rem;
height: 2.25rem;
}
.MonthGrid {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.MonthRow {
display: flex;
gap: 0.25rem;
}
.MonthCell {
flex: 1;
height: 2.5rem;
}
.List {
box-sizing: border-box;
display: flex;
flex-direction: column;
gap: 0.125rem;
width: 8rem;
max-height: 14rem;
overflow-y: auto;
font-size: 0.875rem;
line-height: 1.25rem;
font-variant-numeric: tabular-nums;
}
.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);
}
}
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Title {
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 0;
border-radius: 0.375rem;
font: inherit;
font-weight: 600;
color: inherit;
background-color: transparent;
cursor: pointer;
&:hover:not(:disabled, [aria-disabled='true']) {
background-color: oklch(97% 0 0deg);
@media (prefers-color-scheme: dark) {
background-color: oklch(26.9% 0 0deg);
}
}
&:is(:disabled, [aria-disabled='true']) {
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;
}
}
}
.Description,
.Error {
margin: 0;
font-size: 0.875rem;
line-height: 1.25rem;
}
.Description {
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Error {
color: oklch(50.5% 0.213 27.518deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.4% 0.191 22.216deg);
}
}
.Value {
margin: 0;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}<script setup lang="ts">
import { useId } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import { DateField } from '@vase-ui/vue/date-field';
import { DatePicker } from '@vase-ui/vue/date-picker';
import { Popover } from '@vase-ui/vue/popover';
const id = useId();
const defaultValue = Temporal.PlainDate.from('2026-11-18');
const buttonClassName =
'h-8 w-8 cursor-pointer rounded-md outline-0 hover:not-disabled:not-aria-disabled:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950 disabled:cursor-default disabled:opacity-40 aria-disabled:cursor-default aria-disabled:opacity-40 dark:hover:not-disabled:not-aria-disabled:bg-neutral-800 dark:focus-visible:outline-white';
const dayButtonClassName =
'box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950 data-outside-month:not-data-selected:text-neutral-500 data-selected:bg-neutral-950 data-selected:text-white aria-[current=date]:border-neutral-400 disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:bg-neutral-800 dark:focus-visible:outline-white dark:data-selected:bg-white dark:data-selected: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"
>Departure date</label
>
<DatePicker.Root :default-value="defaultValue" locale="en-US">
<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"
>
<DatePicker.Field :id="id" class="flex items-center px-2">
<DateField.Input
class="flex items-center text-sm font-normal tabular-nums any-pointer-coarse:text-base"
>
<template #segment="{ segment }">
<DateField.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"
/>
<DateField.Literal
v-else
:segment="segment"
class="whitespace-pre text-neutral-600 dark:text-neutral-400"
/>
</template>
</DateField.Input>
</DatePicker.Field>
<DatePicker.Trigger
aria-label="Choose date"
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"
>
<rect x="2.5" y="3.5" width="11" height="10" />
<path d="M2.5 6.5h11M5.5 2v3M10.5 2v3" />
</svg>
</DatePicker.Trigger>
</div>
<Popover.Portal>
<DatePicker.Positioner :side-offset="4">
<Transition :enter-from-class="popupHiddenClass" :leave-to-class="popupHiddenClass">
<DatePicker.Popup
aria-label="Choose a departure date"
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"
>
<DatePicker.Calendar class="relative box-border w-68 text-sm">
<div class="absolute top-0 right-0 flex gap-1">
<Calendar.PreviousButton :class="buttonClassName"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton :class="buttonClassName">›</Calendar.NextButton>
</div>
<Calendar.Months>
<template #month="{ month }">
<Calendar.Month :month="month">
<Calendar.Caption class="mb-2 flex h-8 items-center font-semibold" />
<Calendar.Grid class="w-full table-fixed border-collapse">
<Calendar.GridHeader>
<Calendar.GridHeaderRow>
<template #weekday="{ weekday }">
<Calendar.Weekday
:weekday="weekday"
class="py-1 text-center text-xs font-medium text-neutral-600 dark:text-neutral-400"
/>
</template>
</Calendar.GridHeaderRow>
</Calendar.GridHeader>
<Calendar.GridBody>
<template #week="{ week }">
<Calendar.Week :week="week">
<template #day="{ day }">
<Calendar.Day :day="day" class="p-0 text-center">
<Calendar.DayButton :class="dayButtonClassName" />
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</DatePicker.Calendar>
</DatePicker.Popup>
</Transition>
</DatePicker.Positioner>
</Popover.Portal>
</DatePicker.Root>
</div>
</template>Usage guidelines
- The picker needs
Temporal: Load aTemporalpolyfill for an engine that has none, such as Safari and Node.js 24. Use TypeScript 6.0, or setskipLibCheck. See Dates and times. - Form controls must have an accessible name: Put the picker in a
Fieldwith aField.Label, giveDatePicker.Fieldanaria-labelor anaria-labelledby, or point a<label for>at theidofDatePicker.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
DatePicker.Triggercontent or anaria-labelin the language of the page. See Show the value in the trigger. - The popup must have a name: Give
DatePicker.Popupanaria-label, or put aPopover.Titlein it. - The time field must have a name: Give
DatePicker.TimeFieldanaria-label. AFieldaround the picker does not name it.
Anatomy
Import the component and assemble its parts:
<script setup lang="ts">
import { Calendar } from '@vase-ui/vue/calendar';
import { DateField } from '@vase-ui/vue/date-field';
import { DatePicker } from '@vase-ui/vue/date-picker';
import { Popover } from '@vase-ui/vue/popover';
import { TimeField } from '@vase-ui/vue/time-field';
</script>
<template>
<DatePicker.Root>
<DatePicker.Field>
<DateField.Input />
</DatePicker.Field>
<DatePicker.Trigger aria-label="Choose date" />
<Popover.Portal>
<DatePicker.Positioner>
<DatePicker.Popup aria-label="Choose a date">
<DatePicker.Calendar>
<Calendar.PreviousButton />
<Calendar.NextButton />
<Calendar.Months>
<template #month="{ month }">
<Calendar.Month :month="month">
<Calendar.Caption />
<Calendar.Grid>
<Calendar.GridHeader>
<Calendar.GridHeaderRow>
<template #weekday="{ weekday }">
<Calendar.Weekday :weekday="weekday" />
</template>
</Calendar.GridHeaderRow>
</Calendar.GridHeader>
<Calendar.GridBody>
<template #week="{ week }">
<Calendar.Week :week="week">
<template #day="{ day }">
<Calendar.Day :day="day">
<Calendar.DayButton />
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</DatePicker.Calendar>
<DatePicker.TimeField aria-label="Time">
<TimeField.Input />
</DatePicker.TimeField>
<Popover.Close />
</DatePicker.Popup>
</DatePicker.Positioner>
</Popover.Portal>
</DatePicker.Root>
</template>Examples
Date and time
To pick a date and a time, put a date picker and a Time Picker side by side. Keep the date and the time each in a ref of its own, and join them with toPlainDateTime. A picker gives null while its field has an empty segment. With a ref for each part, an empty segment in one field does not change the other field.
One picker can also hold a date and a time. With a granularity that has a time, or a value with a time, the field shows the time segments, and a press on a day keeps the time. DatePicker.TimeField is then a field for that time in the popup. The popup stays open after a pick, so give it a Popover.Close.
Value: 2026-11-18T09:30:00
<script setup lang="ts">
import { computed, shallowRef, useId } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import { DateField } from '@vase-ui/vue/date-field';
import { DatePicker } from '@vase-ui/vue/date-picker';
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 labelId = useId();
const meetingDate = shallowRef<Temporal.PlainDate | null>(Temporal.PlainDate.from('2026-11-18'));
const meetingTime = shallowRef<Temporal.PlainTime | null>(Temporal.PlainTime.from('09:30'));
// A field has no value while one of its segments is empty.
const value = computed(() =>
meetingDate.value && meetingTime.value
? meetingDate.value.toPlainDateTime(meetingTime.value)
: null,
);
const popupHiddenClass = styles.PopupHidden;
</script>
<template>
<div role="group" :aria-labelledby="labelId" :class="styles.Field">
<div :id="labelId" :class="styles.Label">Meeting time</div>
<div :class="styles.Row">
<DatePicker.Root v-model="meetingDate" locale="en-US">
<div :class="styles.Control">
<DatePicker.Field aria-label="Date" :class="styles.Group">
<DateField.Input :class="styles.Input">
<template #segment="{ segment }">
<DateField.Segment
v-if="segment.editable"
:segment="segment"
:class="styles.Segment"
/>
<DateField.Literal v-else :segment="segment" :class="styles.Literal" />
</template>
</DateField.Input>
</DatePicker.Field>
<DatePicker.Trigger aria-label="Choose date" :class="styles.Trigger">
<svg
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-linecap="square"
>
<rect x="2.5" y="3.5" width="11" height="10" />
<path d="M2.5 6.5h11M5.5 2v3M10.5 2v3" />
</svg>
</DatePicker.Trigger>
</div>
<Popover.Portal>
<DatePicker.Positioner :side-offset="4">
<Transition :enter-from-class="popupHiddenClass" :leave-to-class="popupHiddenClass">
<DatePicker.Popup aria-label="Choose a meeting date" :class="styles.Popup">
<DatePicker.Calendar :class="styles.Calendar">
<div :class="styles.Nav">
<Calendar.PreviousButton :class="styles.Button"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton :class="styles.Button">›</Calendar.NextButton>
</div>
<Calendar.Months>
<template #month="{ month }">
<Calendar.Month :month="month">
<Calendar.Caption :class="styles.Caption" />
<Calendar.Grid :class="styles.Grid">
<Calendar.GridHeader>
<Calendar.GridHeaderRow>
<template #weekday="{ weekday }">
<Calendar.Weekday :weekday="weekday" :class="styles.Weekday" />
</template>
</Calendar.GridHeaderRow>
</Calendar.GridHeader>
<Calendar.GridBody>
<template #week="{ week }">
<Calendar.Week :week="week">
<template #day="{ day }">
<Calendar.Day :day="day" :class="styles.Day">
<Calendar.DayButton :class="styles.DayButton" />
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</DatePicker.Calendar>
</DatePicker.Popup>
</Transition>
</DatePicker.Positioner>
</Popover.Portal>
</DatePicker.Root>
<TimePicker.Root v-model="meetingTime" locale="en-US" :hour-cycle="12">
<div :class="styles.Control">
<TimePicker.Field aria-label="Time" :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>
<p :class="styles.Value">Value: {{ value?.toString() ?? 'none' }}</p>
</div>
</template>.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;
}
}
.Row {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.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);
}
.Calendar {
position: relative;
box-sizing: border-box;
width: 17rem;
font-size: 0.875rem;
line-height: 1.25rem;
}
.Nav {
position: absolute;
top: 0;
right: 0;
display: flex;
gap: 0.25rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Button {
width: 2rem;
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
&:hover:not(:disabled, [aria-disabled='true']) {
background-color: oklch(97% 0 0deg);
@media (prefers-color-scheme: dark) {
background-color: oklch(26.9% 0 0deg);
}
}
&:is(:disabled, [aria-disabled='true']) {
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;
}
}
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday {
padding: 0.25rem 0;
font-size: 0.75rem;
font-weight: 500;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.MonthCell {
box-sizing: border-box;
margin: 0;
padding: 0;
border: 1px solid transparent;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
&:hover:not([data-selected], [aria-selected='true'], :disabled) {
background-color: oklch(97% 0 0deg);
@media (prefers-color-scheme: dark) {
background-color: oklch(26.9% 0 0deg);
}
}
&[aria-current='date'] {
border-color: oklch(70.8% 0 0deg);
}
&:is([data-selected], [aria-selected='true']) {
color: white;
background-color: oklch(14.5% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(14.5% 0 0deg);
background-color: white;
}
}
&[data-outside-month]:not([data-selected]) {
color: oklch(55.6% 0 0deg);
}
&:disabled {
cursor: default;
opacity: 0.4;
}
&:focus-visible {
outline: 2px solid oklch(14.5% 0 0deg);
outline-offset: 2px;
@media (prefers-color-scheme: dark) {
outline-color: white;
}
}
}
.DayButton {
width: 2.25rem;
height: 2.25rem;
}
.MonthGrid {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.MonthRow {
display: flex;
gap: 0.25rem;
}
.MonthCell {
flex: 1;
height: 2.5rem;
}
.List {
box-sizing: border-box;
display: flex;
flex-direction: column;
gap: 0.125rem;
width: 8rem;
max-height: 14rem;
overflow-y: auto;
font-size: 0.875rem;
line-height: 1.25rem;
font-variant-numeric: tabular-nums;
}
.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);
}
}
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Title {
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 0;
border-radius: 0.375rem;
font: inherit;
font-weight: 600;
color: inherit;
background-color: transparent;
cursor: pointer;
&:hover:not(:disabled, [aria-disabled='true']) {
background-color: oklch(97% 0 0deg);
@media (prefers-color-scheme: dark) {
background-color: oklch(26.9% 0 0deg);
}
}
&:is(:disabled, [aria-disabled='true']) {
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;
}
}
}
.Description,
.Error {
margin: 0;
font-size: 0.875rem;
line-height: 1.25rem;
}
.Description {
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Error {
color: oklch(50.5% 0.213 27.518deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.4% 0.191 22.216deg);
}
}
.Value {
margin: 0;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}<script setup lang="ts">
import { computed, shallowRef, useId } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import { DateField } from '@vase-ui/vue/date-field';
import { DatePicker } from '@vase-ui/vue/date-picker';
import { TimeField } from '@vase-ui/vue/time-field';
import { TimePicker } from '@vase-ui/vue/time-picker';
import { Popover } from '@vase-ui/vue/popover';
const labelId = useId();
const meetingDate = shallowRef<Temporal.PlainDate | null>(Temporal.PlainDate.from('2026-11-18'));
const meetingTime = shallowRef<Temporal.PlainTime | null>(Temporal.PlainTime.from('09:30'));
// A field has no value while one of its segments is empty.
const value = computed(() =>
meetingDate.value && meetingTime.value
? meetingDate.value.toPlainDateTime(meetingTime.value)
: null,
);
const buttonClassName =
'h-8 w-8 cursor-pointer rounded-md outline-0 hover:not-disabled:not-aria-disabled:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950 disabled:cursor-default disabled:opacity-40 aria-disabled:cursor-default aria-disabled:opacity-40 dark:hover:not-disabled:not-aria-disabled:bg-neutral-800 dark:focus-visible:outline-white';
const dayButtonClassName =
'box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950 data-outside-month:not-data-selected:text-neutral-500 data-selected:bg-neutral-950 data-selected:text-white aria-[current=date]:border-neutral-400 disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:bg-neutral-800 dark:focus-visible:outline-white dark:data-selected:bg-white dark:data-selected:text-neutral-950';
const popupHiddenClass = 'scale-[0.98] opacity-0';
</script>
<template>
<div role="group" :aria-labelledby="labelId" class="flex flex-col items-start gap-1">
<div :id="labelId" class="text-sm font-bold text-neutral-950 dark:text-white">Meeting time</div>
<div class="flex flex-wrap gap-2">
<DatePicker.Root v-model="meetingDate" locale="en-US">
<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"
>
<DatePicker.Field aria-label="Date" class="flex items-center px-2">
<DateField.Input
class="flex items-center text-sm font-normal tabular-nums any-pointer-coarse:text-base"
>
<template #segment="{ segment }">
<DateField.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"
/>
<DateField.Literal
v-else
:segment="segment"
class="whitespace-pre text-neutral-600 dark:text-neutral-400"
/>
</template>
</DateField.Input>
</DatePicker.Field>
<DatePicker.Trigger
aria-label="Choose date"
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"
>
<rect x="2.5" y="3.5" width="11" height="10" />
<path d="M2.5 6.5h11M5.5 2v3M10.5 2v3" />
</svg>
</DatePicker.Trigger>
</div>
<Popover.Portal>
<DatePicker.Positioner :side-offset="4">
<Transition :enter-from-class="popupHiddenClass" :leave-to-class="popupHiddenClass">
<DatePicker.Popup
aria-label="Choose a meeting date"
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"
>
<DatePicker.Calendar class="relative box-border w-68 text-sm">
<div class="absolute top-0 right-0 flex gap-1">
<Calendar.PreviousButton :class="buttonClassName"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton :class="buttonClassName">›</Calendar.NextButton>
</div>
<Calendar.Months>
<template #month="{ month }">
<Calendar.Month :month="month">
<Calendar.Caption class="mb-2 flex h-8 items-center font-semibold" />
<Calendar.Grid class="w-full table-fixed border-collapse">
<Calendar.GridHeader>
<Calendar.GridHeaderRow>
<template #weekday="{ weekday }">
<Calendar.Weekday
:weekday="weekday"
class="py-1 text-center text-xs font-medium text-neutral-600 dark:text-neutral-400"
/>
</template>
</Calendar.GridHeaderRow>
</Calendar.GridHeader>
<Calendar.GridBody>
<template #week="{ week }">
<Calendar.Week :week="week">
<template #day="{ day }">
<Calendar.Day :day="day" class="p-0 text-center">
<Calendar.DayButton :class="dayButtonClassName" />
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</DatePicker.Calendar>
</DatePicker.Popup>
</Transition>
</DatePicker.Positioner>
</Popover.Portal>
</DatePicker.Root>
<TimePicker.Root v-model="meetingTime" 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 aria-label="Time" 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-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-disabled:cursor-default aria-disabled:opacity-40 aria-selected:bg-neutral-950 aria-selected:text-white aria-selected:focus-visible:outline-white dark:hover:not-disabled:not-aria-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>
<p class="text-sm text-neutral-600 dark:text-neutral-400">
Value: {{ value?.toString() ?? 'none' }}
</p>
</div>
</template>Month picker
A Temporal.PlainYearMonth value, or granularity="month", makes a picker for a month. The calendar then shows the months of a year, and a press on a month selects it.
<script setup lang="ts">
import { useId } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import { DateField } from '@vase-ui/vue/date-field';
import { DatePicker } from '@vase-ui/vue/date-picker';
import { Popover } from '@vase-ui/vue/popover';
import styles from '../../_index.module.css';
const id = useId();
const defaultValue = Temporal.PlainYearMonth.from('2026-11');
const popupHiddenClass = styles.PopupHidden;
</script>
<template>
<div :class="styles.Field">
<label :for="id" :class="styles.Label">Billing month</label>
<DatePicker.Root :default-value="defaultValue" locale="en-US">
<div :class="styles.Control">
<DatePicker.Field :id="id" :class="styles.Group">
<DateField.Input :class="styles.Input">
<template #segment="{ segment }">
<DateField.Segment
v-if="segment.editable"
:segment="segment"
:class="styles.Segment"
/>
<DateField.Literal v-else :segment="segment" :class="styles.Literal" />
</template>
</DateField.Input>
</DatePicker.Field>
<DatePicker.Trigger aria-label="Choose month" :class="styles.Trigger">
<svg
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-linecap="square"
>
<rect x="2.5" y="3.5" width="11" height="10" />
<path d="M2.5 6.5h11M5.5 2v3M10.5 2v3" />
</svg>
</DatePicker.Trigger>
</div>
<Popover.Portal>
<DatePicker.Positioner :side-offset="4">
<Transition :enter-from-class="popupHiddenClass" :leave-to-class="popupHiddenClass">
<DatePicker.Popup aria-label="Choose a billing month" :class="styles.Popup">
<DatePicker.Calendar :class="styles.Calendar">
<div :class="styles.Header">
<Calendar.PreviousButton :class="styles.Button">‹</Calendar.PreviousButton>
<Calendar.ViewTrigger :class="styles.Title" />
<Calendar.NextButton :class="styles.Button">›</Calendar.NextButton>
</div>
<Calendar.MonthGrid :class="styles.MonthGrid">
<template #row="{ months }">
<Calendar.MonthGridRow :class="styles.MonthRow">
<Calendar.MonthCell
v-for="month in months"
:key="month.toString()"
:month="month"
:class="styles.MonthCell"
/>
</Calendar.MonthGridRow>
</template>
</Calendar.MonthGrid>
<Calendar.YearGrid :class="styles.MonthGrid">
<template #row="{ years }">
<Calendar.YearGridRow :class="styles.MonthRow">
<Calendar.YearCell
v-for="year in years"
:key="year.toString()"
:year="year"
:class="styles.MonthCell"
/>
</Calendar.YearGridRow>
</template>
</Calendar.YearGrid>
</DatePicker.Calendar>
</DatePicker.Popup>
</Transition>
</DatePicker.Positioner>
</Popover.Portal>
</DatePicker.Root>
</div>
</template>.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;
}
}
.Row {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.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);
}
.Calendar {
position: relative;
box-sizing: border-box;
width: 17rem;
font-size: 0.875rem;
line-height: 1.25rem;
}
.Nav {
position: absolute;
top: 0;
right: 0;
display: flex;
gap: 0.25rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Button {
width: 2rem;
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
&:hover:not(:disabled, [aria-disabled='true']) {
background-color: oklch(97% 0 0deg);
@media (prefers-color-scheme: dark) {
background-color: oklch(26.9% 0 0deg);
}
}
&:is(:disabled, [aria-disabled='true']) {
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;
}
}
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday {
padding: 0.25rem 0;
font-size: 0.75rem;
font-weight: 500;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.MonthCell {
box-sizing: border-box;
margin: 0;
padding: 0;
border: 1px solid transparent;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
&:hover:not([data-selected], [aria-selected='true'], :disabled) {
background-color: oklch(97% 0 0deg);
@media (prefers-color-scheme: dark) {
background-color: oklch(26.9% 0 0deg);
}
}
&[aria-current='date'] {
border-color: oklch(70.8% 0 0deg);
}
&:is([data-selected], [aria-selected='true']) {
color: white;
background-color: oklch(14.5% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(14.5% 0 0deg);
background-color: white;
}
}
&[data-outside-month]:not([data-selected]) {
color: oklch(55.6% 0 0deg);
}
&:disabled {
cursor: default;
opacity: 0.4;
}
&:focus-visible {
outline: 2px solid oklch(14.5% 0 0deg);
outline-offset: 2px;
@media (prefers-color-scheme: dark) {
outline-color: white;
}
}
}
.DayButton {
width: 2.25rem;
height: 2.25rem;
}
.MonthGrid {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.MonthRow {
display: flex;
gap: 0.25rem;
}
.MonthCell {
flex: 1;
height: 2.5rem;
}
.List {
box-sizing: border-box;
display: flex;
flex-direction: column;
gap: 0.125rem;
width: 8rem;
max-height: 14rem;
overflow-y: auto;
font-size: 0.875rem;
line-height: 1.25rem;
font-variant-numeric: tabular-nums;
}
.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);
}
}
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Title {
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 0;
border-radius: 0.375rem;
font: inherit;
font-weight: 600;
color: inherit;
background-color: transparent;
cursor: pointer;
&:hover:not(:disabled, [aria-disabled='true']) {
background-color: oklch(97% 0 0deg);
@media (prefers-color-scheme: dark) {
background-color: oklch(26.9% 0 0deg);
}
}
&:is(:disabled, [aria-disabled='true']) {
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;
}
}
}
.Description,
.Error {
margin: 0;
font-size: 0.875rem;
line-height: 1.25rem;
}
.Description {
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Error {
color: oklch(50.5% 0.213 27.518deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.4% 0.191 22.216deg);
}
}
.Value {
margin: 0;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}<script setup lang="ts">
import { useId } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import { DateField } from '@vase-ui/vue/date-field';
import { DatePicker } from '@vase-ui/vue/date-picker';
import { Popover } from '@vase-ui/vue/popover';
const id = useId();
const defaultValue = Temporal.PlainYearMonth.from('2026-11');
const buttonClassName =
'h-8 w-8 cursor-pointer rounded-md outline-0 hover:not-disabled:not-aria-disabled:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950 disabled:cursor-default disabled:opacity-40 aria-disabled:cursor-default aria-disabled:opacity-40 dark:hover:not-disabled:not-aria-disabled:bg-neutral-800 dark:focus-visible:outline-white';
const titleClassName =
'h-8 cursor-pointer rounded-md px-2 font-semibold outline-0 hover:not-disabled:not-aria-disabled:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950 disabled:cursor-default disabled:opacity-40 aria-disabled:cursor-default aria-disabled:opacity-40 dark:hover:not-disabled:not-aria-disabled:bg-neutral-800 dark:focus-visible:outline-white';
const cellClassName =
'box-border h-10 flex-1 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-aria-selected:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950 aria-[current=date]:border-neutral-400 disabled:cursor-default disabled:opacity-40 aria-selected:bg-neutral-950 aria-selected:text-white dark:hover:enabled:not-aria-selected:bg-neutral-800 dark:focus-visible:outline-white dark:aria-selected:bg-white dark:aria-selected: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"
>Billing month</label
>
<DatePicker.Root :default-value="defaultValue" locale="en-US">
<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"
>
<DatePicker.Field :id="id" class="flex items-center px-2">
<DateField.Input
class="flex items-center text-sm font-normal tabular-nums any-pointer-coarse:text-base"
>
<template #segment="{ segment }">
<DateField.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"
/>
<DateField.Literal
v-else
:segment="segment"
class="whitespace-pre text-neutral-600 dark:text-neutral-400"
/>
</template>
</DateField.Input>
</DatePicker.Field>
<DatePicker.Trigger
aria-label="Choose month"
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"
>
<rect x="2.5" y="3.5" width="11" height="10" />
<path d="M2.5 6.5h11M5.5 2v3M10.5 2v3" />
</svg>
</DatePicker.Trigger>
</div>
<Popover.Portal>
<DatePicker.Positioner :side-offset="4">
<Transition :enter-from-class="popupHiddenClass" :leave-to-class="popupHiddenClass">
<DatePicker.Popup
aria-label="Choose a billing month"
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"
>
<DatePicker.Calendar class="relative box-border w-68 text-sm">
<div class="mb-2 flex items-center justify-between">
<Calendar.PreviousButton :class="buttonClassName"
>‹</Calendar.PreviousButton
>
<Calendar.ViewTrigger :class="titleClassName" />
<Calendar.NextButton :class="buttonClassName">›</Calendar.NextButton>
</div>
<Calendar.MonthGrid class="flex flex-col gap-1">
<template #row="{ months }">
<Calendar.MonthGridRow class="flex gap-1">
<Calendar.MonthCell
v-for="month in months"
:key="month.toString()"
:month="month"
:class="cellClassName"
/>
</Calendar.MonthGridRow>
</template>
</Calendar.MonthGrid>
<Calendar.YearGrid class="flex flex-col gap-1">
<template #row="{ years }">
<Calendar.YearGridRow class="flex gap-1">
<Calendar.YearCell
v-for="year in years"
:key="year.toString()"
:year="year"
:class="cellClassName"
/>
</Calendar.YearGridRow>
</template>
</Calendar.YearGrid>
</DatePicker.Calendar>
</DatePicker.Popup>
</Transition>
</DatePicker.Positioner>
</Popover.Portal>
</DatePicker.Root>
</div>
</template>In a form
Put the picker in a Field to show the errors of its validation. The form input of DatePicker.Field has the type of the value, so min and max give rangeUnderflow and rangeOverflow, and required gives valueMissing. The picker sets a customError for a date that unavailableDates matches, as Date Field does.
Choose a weekday in November 2026.
<script setup lang="ts">
import { Calendar } from '@vase-ui/vue/calendar';
import { DateField } from '@vase-ui/vue/date-field';
import { DatePicker } from '@vase-ui/vue/date-picker';
import { Field } from '@vase-ui/vue/field';
import { Popover } from '@vase-ui/vue/popover';
import styles from '../../_index.module.css';
const defaultValue = Temporal.PlainDate.from('2026-12-01');
const minDate = Temporal.PlainDate.from('2026-11-01');
const maxDate = Temporal.PlainDate.from('2026-11-30');
// Saturday and Sunday.
const unavailableDates = { dayOfWeek: [6, 7] };
const popupHiddenClass = styles.PopupHidden;
</script>
<template>
<Field.Root name="checkIn" :class="styles.Field">
<Field.Label :class="styles.Label">Check-in date</Field.Label>
<DatePicker.Root
required
:default-value="defaultValue"
:min="minDate"
:max="maxDate"
:unavailable-dates="unavailableDates"
locale="en-US"
>
<div :class="styles.Control">
<DatePicker.Field :class="styles.Group">
<DateField.Input :class="styles.Input">
<template #segment="{ segment }">
<DateField.Segment
v-if="segment.editable"
:segment="segment"
:class="styles.Segment"
/>
<DateField.Literal v-else :segment="segment" :class="styles.Literal" />
</template>
</DateField.Input>
</DatePicker.Field>
<DatePicker.Trigger aria-label="Choose date" :class="styles.Trigger">
<svg
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-linecap="square"
>
<rect x="2.5" y="3.5" width="11" height="10" />
<path d="M2.5 6.5h11M5.5 2v3M10.5 2v3" />
</svg>
</DatePicker.Trigger>
</div>
<Popover.Portal>
<DatePicker.Positioner :side-offset="4">
<Transition :enter-from-class="popupHiddenClass" :leave-to-class="popupHiddenClass">
<DatePicker.Popup aria-label="Choose a check-in date" :class="styles.Popup">
<DatePicker.Calendar :class="styles.Calendar">
<div :class="styles.Nav">
<Calendar.PreviousButton :class="styles.Button">‹</Calendar.PreviousButton>
<Calendar.NextButton :class="styles.Button">›</Calendar.NextButton>
</div>
<Calendar.Months>
<template #month="{ month }">
<Calendar.Month :month="month">
<Calendar.Caption :class="styles.Caption" />
<Calendar.Grid :class="styles.Grid">
<Calendar.GridHeader>
<Calendar.GridHeaderRow>
<template #weekday="{ weekday }">
<Calendar.Weekday :weekday="weekday" :class="styles.Weekday" />
</template>
</Calendar.GridHeaderRow>
</Calendar.GridHeader>
<Calendar.GridBody>
<template #week="{ week }">
<Calendar.Week :week="week">
<template #day="{ day }">
<Calendar.Day :day="day" :class="styles.Day">
<Calendar.DayButton :class="styles.DayButton" />
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</DatePicker.Calendar>
</DatePicker.Popup>
</Transition>
</DatePicker.Positioner>
</Popover.Portal>
</DatePicker.Root>
<Field.Description :class="styles.Description"
>Choose a weekday in November 2026.</Field.Description
>
<Field.Error :class="styles.Error" />
</Field.Root>
</template>.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;
}
}
.Row {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.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);
}
.Calendar {
position: relative;
box-sizing: border-box;
width: 17rem;
font-size: 0.875rem;
line-height: 1.25rem;
}
.Nav {
position: absolute;
top: 0;
right: 0;
display: flex;
gap: 0.25rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Button {
width: 2rem;
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
&:hover:not(:disabled, [aria-disabled='true']) {
background-color: oklch(97% 0 0deg);
@media (prefers-color-scheme: dark) {
background-color: oklch(26.9% 0 0deg);
}
}
&:is(:disabled, [aria-disabled='true']) {
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;
}
}
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday {
padding: 0.25rem 0;
font-size: 0.75rem;
font-weight: 500;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.MonthCell {
box-sizing: border-box;
margin: 0;
padding: 0;
border: 1px solid transparent;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
&:hover:not([data-selected], [aria-selected='true'], :disabled) {
background-color: oklch(97% 0 0deg);
@media (prefers-color-scheme: dark) {
background-color: oklch(26.9% 0 0deg);
}
}
&[aria-current='date'] {
border-color: oklch(70.8% 0 0deg);
}
&:is([data-selected], [aria-selected='true']) {
color: white;
background-color: oklch(14.5% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(14.5% 0 0deg);
background-color: white;
}
}
&[data-outside-month]:not([data-selected]) {
color: oklch(55.6% 0 0deg);
}
&:disabled {
cursor: default;
opacity: 0.4;
}
&:focus-visible {
outline: 2px solid oklch(14.5% 0 0deg);
outline-offset: 2px;
@media (prefers-color-scheme: dark) {
outline-color: white;
}
}
}
.DayButton {
width: 2.25rem;
height: 2.25rem;
}
.MonthGrid {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.MonthRow {
display: flex;
gap: 0.25rem;
}
.MonthCell {
flex: 1;
height: 2.5rem;
}
.List {
box-sizing: border-box;
display: flex;
flex-direction: column;
gap: 0.125rem;
width: 8rem;
max-height: 14rem;
overflow-y: auto;
font-size: 0.875rem;
line-height: 1.25rem;
font-variant-numeric: tabular-nums;
}
.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);
}
}
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Title {
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 0;
border-radius: 0.375rem;
font: inherit;
font-weight: 600;
color: inherit;
background-color: transparent;
cursor: pointer;
&:hover:not(:disabled, [aria-disabled='true']) {
background-color: oklch(97% 0 0deg);
@media (prefers-color-scheme: dark) {
background-color: oklch(26.9% 0 0deg);
}
}
&:is(:disabled, [aria-disabled='true']) {
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;
}
}
}
.Description,
.Error {
margin: 0;
font-size: 0.875rem;
line-height: 1.25rem;
}
.Description {
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Error {
color: oklch(50.5% 0.213 27.518deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.4% 0.191 22.216deg);
}
}
.Value {
margin: 0;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}<script setup lang="ts">
import { Calendar } from '@vase-ui/vue/calendar';
import { DateField } from '@vase-ui/vue/date-field';
import { DatePicker } from '@vase-ui/vue/date-picker';
import { Field } from '@vase-ui/vue/field';
import { Popover } from '@vase-ui/vue/popover';
const defaultValue = Temporal.PlainDate.from('2026-12-01');
const minDate = Temporal.PlainDate.from('2026-11-01');
const maxDate = Temporal.PlainDate.from('2026-11-30');
// Saturday and Sunday.
const unavailableDates = { dayOfWeek: [6, 7] };
const buttonClassName =
'h-8 w-8 cursor-pointer rounded-md outline-0 hover:not-disabled:not-aria-disabled:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950 disabled:cursor-default disabled:opacity-40 aria-disabled:cursor-default aria-disabled:opacity-40 dark:hover:not-disabled:not-aria-disabled:bg-neutral-800 dark:focus-visible:outline-white';
const dayButtonClassName =
'box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950 data-outside-month:not-data-selected:text-neutral-500 data-selected:bg-neutral-950 data-selected:text-white aria-[current=date]:border-neutral-400 disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:bg-neutral-800 dark:focus-visible:outline-white dark:data-selected:bg-white dark:data-selected:text-neutral-950';
const popupHiddenClass = 'scale-[0.98] opacity-0';
</script>
<template>
<Field.Root name="checkIn" class="flex flex-col items-start gap-1">
<Field.Label class="text-sm font-bold text-neutral-950 dark:text-white"
>Check-in date</Field.Label
>
<DatePicker.Root
required
:default-value="defaultValue"
:min="minDate"
:max="maxDate"
:unavailable-dates="unavailableDates"
locale="en-US"
>
<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"
>
<DatePicker.Field class="flex items-center px-2">
<DateField.Input
class="flex items-center text-sm font-normal tabular-nums any-pointer-coarse:text-base"
>
<template #segment="{ segment }">
<DateField.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"
/>
<DateField.Literal
v-else
:segment="segment"
class="whitespace-pre text-neutral-600 dark:text-neutral-400"
/>
</template>
</DateField.Input>
</DatePicker.Field>
<DatePicker.Trigger
aria-label="Choose date"
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"
>
<rect x="2.5" y="3.5" width="11" height="10" />
<path d="M2.5 6.5h11M5.5 2v3M10.5 2v3" />
</svg>
</DatePicker.Trigger>
</div>
<Popover.Portal>
<DatePicker.Positioner :side-offset="4">
<Transition :enter-from-class="popupHiddenClass" :leave-to-class="popupHiddenClass">
<DatePicker.Popup
aria-label="Choose a check-in date"
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"
>
<DatePicker.Calendar class="relative box-border w-68 text-sm">
<div class="absolute top-0 right-0 flex gap-1">
<Calendar.PreviousButton :class="buttonClassName"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton :class="buttonClassName">›</Calendar.NextButton>
</div>
<Calendar.Months>
<template #month="{ month }">
<Calendar.Month :month="month">
<Calendar.Caption class="mb-2 flex h-8 items-center font-semibold" />
<Calendar.Grid class="w-full table-fixed border-collapse">
<Calendar.GridHeader>
<Calendar.GridHeaderRow>
<template #weekday="{ weekday }">
<Calendar.Weekday
:weekday="weekday"
class="py-1 text-center text-xs font-medium text-neutral-600 dark:text-neutral-400"
/>
</template>
</Calendar.GridHeaderRow>
</Calendar.GridHeader>
<Calendar.GridBody>
<template #week="{ week }">
<Calendar.Week :week="week">
<template #day="{ day }">
<Calendar.Day :day="day" class="p-0 text-center">
<Calendar.DayButton :class="dayButtonClassName" />
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</DatePicker.Calendar>
</DatePicker.Popup>
</Transition>
</DatePicker.Positioner>
</Popover.Portal>
</DatePicker.Root>
<Field.Description class="text-sm text-neutral-600 dark:text-neutral-400"
>Choose a weekday in November 2026.</Field.Description
>
<Field.Error class="text-sm text-red-700 dark:text-red-400" />
</Field.Root>
</template>Show the value in the trigger
The text of the slots of DatePicker.Trigger is the value in the locale, or undefined with no value. Show it in the trigger, so that the text is the name of the trigger. A server can have other Intl data than the browser, so give the element of the text data-allow-mismatch="text":
<script setup lang="ts">
import { DateField } from '@vase-ui/vue/date-field';
import { DatePicker } from '@vase-ui/vue/date-picker';
</script>
<template>
<DatePicker.Root>
<DatePicker.Field aria-label="Departure date">
<DateField.Input />
</DatePicker.Field>
<DatePicker.Trigger v-slot="{ text }">
<span data-allow-mismatch="text">{{ text ?? 'Choose date' }}</span>
</DatePicker.Trigger>
</DatePicker.Root>
</template>Keyboard
| Key | Action |
|---|---|
| Alt+Down in the field | Opens the popup. The focus goes to the day or the month that has the tab stop. |
| Enter, Space | On the trigger, opens the popup. On a day or a month, selects it and closes the popup, unless closeOnSelect is false. |
| Escape | Closes the popup and gives the focus back to the trigger. The value stays. |
| Tab | Moves the focus through the popup in the order of the page, after the trigger. |
| The keys of Date Field and Calendar | Do the same actions in the field and in the calendar. |
API reference
DatePicker.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
| Prop | Type | Default | Description |
|---|---|---|---|
calendar | string | undefined | The calendar that the field and the calendar show, such as gregory or persian. The default
is the calendar of a value that is not ISO, else the calendar of the locale. A value keeps its
own calendar. | |
closeOnSelect | boolean | undefined | A pick in the calendar closes the popup. The default is true for a value with no time, and
false for a value with a time, so that the user can set the time.
In a wrapper that declares this prop, give it the default undefined. | |
defaultOpen | boolean | undefined | false | The popup is open at the mount of an uncontrolled picker. |
defaultValue | Value | null | undefined | The value of a picker with no modelValue, at the mount and at a native reset of the form. | |
disabled | boolean | undefined | false | The user cannot change the value or open the popup. |
forceLeadingZeros | boolean | undefined | false | The day, the month and the hour show a leading zero. |
form | string | undefined | The id of the form of the form input, for a picker outside that form. | |
granularity | DateTimeFieldGranularity | undefined | The last unit that the field shows. With no value, it also gives the kind of a new value:
month a year and month, day a date, and a time unit a date with a time. | |
hideTimeZone | boolean | undefined | false | The field shows no time zone name for a Temporal.ZonedDateTime. |
hourCycle | 12 | 24 | undefined | The hour cycle. The default is the hour cycle of the locale. | |
locale | Intl.LocalesArgument | The locale of each text. The default is the locale of the nearest LocaleProvider, else
en-US. | |
max | DateValue | undefined | The latest value. The calendar disables a later day, and a later value makes the field invalid. A limit with a time also limits the time of a field that shows a time. | |
min | DateValue | undefined | The earliest value. The calendar disables an earlier day, and an earlier value makes the field invalid. A limit with a time also limits the time of a field that shows a time. | |
modal | boolean | "trap-focus" | undefined | false | The modal state of the open popup, as for Popover.Root. |
modelValue | Value | null | undefined | The value: a Temporal.PlainDate, PlainDateTime, ZonedDateTime or PlainYearMonth, or
null for no value. A new value has the kind, the calendar, the time and the zone of the value,
else of defaultValue, else of the last value. | |
name | string | undefined | The name of the form input. The name of a Field wins. | |
open | boolean | undefined | The popup is open. v-model:open binds it. | |
readonly | boolean | undefined | false | The user cannot change the value or open the popup. The field stays in the tab order and in the form data. |
referenceDate | DatePickerRootValue | undefined | Gives the kind, the calendar, the time zone and the hidden units of a first value, and the numbers of an empty segment for an arrow key. | |
required | boolean | undefined | false | The user must give a value before a submit. |
timeZone | string | undefined | The time zone in which the picker reads today. The default is the zone of a
Temporal.ZonedDateTime value, else the zone of the runtime. | |
unavailableDates | DateMatcher | undefined | The dates that the picker refuses: a date, a range, a day of the week, a function or a list. |
Slots
| Slot | Slot props | Description |
|---|---|---|
default | The content of the part. |
Events
| Event | Arguments | Description |
|---|---|---|
valueChange | [value: Value | null, details: DatePickerRootChangeEventDetails] | 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: DatePickerRootOpenChangeEventDetails] | 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
| Member | Type | Description |
|---|---|---|
close | () => void | undefined | Closes the popup with the reason 'imperative-action'. |
DatePicker.Field
The field of the picker: DateField.Root with the value of the picker. It takes the other props
of DateField.Root, such as id, 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
| Slot | Slot props | Description |
|---|---|---|
default | state: DatePickerFieldState | The content of the part. |
Exposed
| Member | Type | Description |
|---|---|---|
element | HTMLElement | null | The element of the part, or null while it is not mounted. |
inputElement | HTMLInputElement | null | The input that gives the value to a form. |
clear | () => void | Empties each segment. update:modelValue follows when the picker had a value. |
DatePicker.Trigger
A button that opens the popup: Popover.Trigger of the picker. The text of its slots is the
value in the locale, or undefined with no value.
Renders a <button> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
disabled | boolean | undefined | false | The user cannot press the trigger. A disabled or read-only picker also disables it. |
Slots
| Slot | Slot props | Description |
|---|---|---|
default | state: DatePickerTriggerStatetext: string | undefined | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: DatePickerTriggerStatetext: string | undefined | Renders your element in place of the element of the part. Bind props with v-bind and elementRef with :ref. |
Exposed
| Member | Type | Description |
|---|---|---|
element | HTMLElement | null | The element of the part, or null while it is not mounted. |
Selectors
| Selector | Description |
|---|---|
[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. |
:disabled | The 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. |
DatePicker.Positioner
Places the popup at the field: Popover.Positioner of the picker.
Renders a <div> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
align | Align | undefined | 'start' | The alignment of the popup on the side of the anchor. |
anchor | Anchor | (() => Anchor) | The anchor of the popup. The default is the first field of the picker, else the trigger. |
Slots
| Slot | Slot props | Description |
|---|---|---|
default | state: DatePickerPositionerState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: DatePickerPositionerState | Renders your element in place of the element of the part. Bind props with v-bind and elementRef with :ref. |
Exposed
| Member | Type | Description |
|---|---|---|
element | HTMLElement | null | The element of the part, or null while it is not mounted. |
Selectors
| Selector | Description |
|---|---|
[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
| Variable | Description |
|---|---|
--anchor-width | The width of the anchor. |
--anchor-height | The height of the anchor. |
--available-width | The width that the popup has before it goes out of its collision boundary. |
--available-height | The height that the popup has before it goes out of its collision boundary. |
--transform-origin | The 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. |
DatePicker.Popup
The container of the calendar: Popover.Popup of the picker. It gives the focus to the
calendar at each open.
Renders a <div> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
initialFocus | FocusTarget | undefined | The element that gets the focus at the open. The default is the day or the month of the tab
stop of the calendar, 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
| Slot | Slot props | Description |
|---|---|---|
default | state: DatePickerPopupState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: DatePickerPopupState | Renders your element in place of the element of the part. Bind props with v-bind and elementRef with :ref. |
Exposed
| Member | Type | Description |
|---|---|---|
element | HTMLElement | null | The element of the part, or null while it is not mounted. |
Selectors
| Selector | Description |
|---|---|
[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. |
DatePicker.Calendar
The calendar of the picker: Calendar.Root with the value of the picker. It takes the other
props and events of Calendar.Root, such as numberOfMonths and monthChange, and it has the
selectors of that part. A pick closes the popup when closeOnSelect of the root allows it.
Renders a <div> element.
Slots
| Slot | Slot props | Description |
|---|---|---|
default | state: DatePickerCalendarState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: DatePickerCalendarState | Renders your element in place of the element of the part. Bind props with v-bind and elementRef with :ref. |
Exposed
| Member | Type | Description |
|---|---|---|
element | HTMLElement | null | The element of the part, or null while it is not mounted. |
focus | (date?: DateValue | undefined) => void | undefined | Gives the focus to date, else to the tab stop. |
DatePicker.TimeField
A field for the time of the value: TimeField.Root with the value of the picker. It takes the
other props of TimeField.Root, such as step, and it has the selectors of that part. It gives
no value to a form, and a Field around the picker does not name it.
Renders a <div> element with a hidden form <input> element in it.
Slots
| Slot | Slot props | Description |
|---|---|---|
default | state: DatePickerTimeFieldState | The content of the part. |
Exposed
| Member | Type | Description |
|---|---|---|
element | HTMLElement | null | The element of the part, or null while it is not mounted. |
clear | () => void | Empties each segment. update:modelValue follows when the picker had a value. |
DatePicker.Root.ChangeEventReason
The reason of valueChange: day-press and month-press for a pick in the calendar, and the other reasons for a change in the field, as in Date Field.
'day-press' | 'month-press' | 'input-change' | 'input-clear' | 'input-paste' | 'keyboard' | 'clear-press'
DatePicker.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'
Differences from Base UI
Base UI has no Date Picker. A person types a date in a field, or picks it in a calendar in a popup. The picker gives one Temporal value to a form.
- https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/examples/datepicker-dialog/
- https://html.spec.whatwg.org/multipage/input.html#date-state-(type=date)
The handbook gives the differences that all components share: Styling, Animation, Composition, Customization, Forms and TypeScript.