Date Range Picker
Two fields to type the first day and the last day of a range in, and a calendar in a popup to pick them.
<script setup lang="ts">
import { useId } from 'vue';
import { DateField } from '@vase-ui/vue/date-field';
import { DateRangePicker } from '@vase-ui/vue/date-range-picker';
import { Calendar } from '@vase-ui/vue/calendar';
import { Popover } from '@vase-ui/vue/popover';
import styles from '../../_index.module.css';
const id = useId();
const defaultValue: [Temporal.PlainDate, Temporal.PlainDate] = [
Temporal.PlainDate.from('2026-11-18'),
Temporal.PlainDate.from('2026-11-22'),
];
const popupHiddenClass = styles.PopupHidden;
</script>
<template>
<div :class="styles.Field">
<label :for="id" :class="styles.Label">Trip dates</label>
<DateRangePicker.Root :default-value="defaultValue" locale="en-US">
<div :class="styles.Control">
<DateRangePicker.StartField aria-label="Start date" :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>
</DateRangePicker.StartField>
<span aria-hidden="true" :class="styles.Separator">–</span>
<DateRangePicker.EndField aria-label="End 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>
</DateRangePicker.EndField>
<DateRangePicker.Trigger aria-label="Choose dates" :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>
</DateRangePicker.Trigger>
</div>
<Popover.Portal>
<DateRangePicker.Positioner :side-offset="4">
<Transition :enter-from-class="popupHiddenClass" :leave-to-class="popupHiddenClass">
<DateRangePicker.Popup aria-label="Choose trip dates" :class="styles.Popup">
<DateRangePicker.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>
</DateRangePicker.Calendar>
</DateRangePicker.Popup>
</Transition>
</DateRangePicker.Positioner>
</Popover.Portal>
</DateRangePicker.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;
}
}
.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);
}
}
.Separator {
color: oklch(43.9% 0 0deg);
user-select: none;
@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;
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 {
border-collapse: collapse;
}
.Weekday {
width: 2.25rem;
height: 2rem;
padding: 0;
color: oklch(43.9% 0 0deg);
font-size: 0.75rem;
font-weight: 400;
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Day {
padding: 0;
text-align: center;
}
.DayButton {
box-sizing: border-box;
width: 2.25rem;
height: 2.25rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
background-color: transparent;
color: inherit;
font: inherit;
cursor: pointer;
-webkit-user-select: none;
user-select: none;
&[aria-current='date'] {
font-weight: 700;
text-decoration: underline;
}
&[data-range-middle] {
border-radius: 0;
background-color: oklch(97% 0 0deg);
@media (prefers-color-scheme: dark) {
background-color: oklch(26.9% 0 0deg);
}
}
&[data-range-start],
&[data-range-end] {
background-color: oklch(14.5% 0 0deg);
color: white;
@media (prefers-color-scheme: dark) {
background-color: white;
color: oklch(14.5% 0 0deg);
}
}
&:disabled {
cursor: default;
opacity: 0.4;
}
&[data-unavailable] {
text-decoration: line-through;
}
&:focus-visible {
position: relative;
z-index: 1;
outline: 2px solid oklch(14.5% 0 0deg);
outline-offset: 2px;
@media (prefers-color-scheme: dark) {
outline-color: white;
}
}
}<script setup lang="ts">
import { useId } from 'vue';
import { DateField } from '@vase-ui/vue/date-field';
import { DateRangePicker } from '@vase-ui/vue/date-range-picker';
import { Calendar } from '@vase-ui/vue/calendar';
import { Popover } from '@vase-ui/vue/popover';
const id = useId();
const defaultValue: [Temporal.PlainDate, Temporal.PlainDate] = [
Temporal.PlainDate.from('2026-11-18'),
Temporal.PlainDate.from('2026-11-22'),
];
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 =
'm-0 box-border size-9 cursor-pointer select-none rounded-md border-0 bg-transparent p-0 font-[inherit] text-inherit focus-visible:relative focus-visible:z-1 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950 disabled:cursor-default disabled:opacity-40 data-range-end:bg-neutral-950 data-range-end:text-white data-range-middle:rounded-none data-range-middle:bg-neutral-100 data-range-start:bg-neutral-950 data-range-start:text-white aria-[current=date]:font-bold aria-[current=date]:underline data-unavailable:line-through dark:focus-visible:outline-white dark:data-range-end:bg-white dark:data-range-end:text-neutral-950 dark:data-range-middle:bg-neutral-800 dark:data-range-start:bg-white dark:data-range-start:text-neutral-950';
const segmentClassName =
'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';
const literalClassName = 'whitespace-pre text-neutral-600 dark:text-neutral-400';
const inputClassName =
'flex items-center text-sm font-normal tabular-nums any-pointer-coarse:text-base';
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">Trip dates</label>
<DateRangePicker.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"
>
<DateRangePicker.StartField aria-label="Start date" :id="id" class="flex items-center px-2">
<DateField.Input :class="inputClassName">
<template #segment="{ segment }">
<DateField.Segment
v-if="segment.editable"
:segment="segment"
:class="segmentClassName"
/>
<DateField.Literal v-else :segment="segment" :class="literalClassName" />
</template>
</DateField.Input>
</DateRangePicker.StartField>
<span aria-hidden="true" class="text-neutral-600 select-none dark:text-neutral-400"
>–</span
>
<DateRangePicker.EndField aria-label="End date" class="flex items-center px-2">
<DateField.Input :class="inputClassName">
<template #segment="{ segment }">
<DateField.Segment
v-if="segment.editable"
:segment="segment"
:class="segmentClassName"
/>
<DateField.Literal v-else :segment="segment" :class="literalClassName" />
</template>
</DateField.Input>
</DateRangePicker.EndField>
<DateRangePicker.Trigger
aria-label="Choose dates"
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>
</DateRangePicker.Trigger>
</div>
<Popover.Portal>
<DateRangePicker.Positioner :side-offset="4">
<Transition :enter-from-class="popupHiddenClass" :leave-to-class="popupHiddenClass">
<DateRangePicker.Popup
aria-label="Choose trip dates"
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"
>
<DateRangePicker.Calendar class="relative box-border 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="border-collapse">
<Calendar.GridHeader>
<Calendar.GridHeaderRow>
<template #weekday="{ weekday }">
<Calendar.Weekday
:weekday="weekday"
class="h-8 w-9 p-0 text-xs font-normal 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>
</DateRangePicker.Calendar>
</DateRangePicker.Popup>
</Transition>
</DateRangePicker.Positioner>
</Popover.Portal>
</DateRangePicker.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. - Each field must have an accessible name: Give each field an
aria-labelin the language of the page, such asStart date. In aField, the label of theFieldjoins that name, as inStart date Trip dates. A field with noaria-labelin aFieldhas the name of the label alone. Thearia-labelledbyof a field replaces both. See the forms guide. - The trigger must have a name: Give
DateRangePicker.Triggercontent or anaria-labelin the language of the page. See Show the range in the trigger. - The popup must have a name: Give
DateRangePicker.Popupanaria-label, or put aPopover.Titlein it.
Anatomy
Import the component and assemble its parts:
<script setup lang="ts">
import { DateField } from '@vase-ui/vue/date-field';
import { DateRangePicker } from '@vase-ui/vue/date-range-picker';
import { Calendar } from '@vase-ui/vue/calendar';
import { Popover } from '@vase-ui/vue/popover';
</script>
<template>
<DateRangePicker.Root>
<DateRangePicker.StartField aria-label="Start date">
<DateField.Input />
</DateRangePicker.StartField>
<DateRangePicker.EndField aria-label="End date">
<DateField.Input />
</DateRangePicker.EndField>
<DateRangePicker.Trigger aria-label="Choose dates" />
<Popover.Portal>
<DateRangePicker.Positioner>
<DateRangePicker.Popup aria-label="Choose dates">
<DateRangePicker.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>
</DateRangePicker.Calendar>
<Popover.Close />
</DateRangePicker.Popup>
</DateRangePicker.Positioner>
</Popover.Portal>
</DateRangePicker.Root>
</template>Examples
In a form
Each field gives its end to a form through its form input. Name them with startName and endName. The form inputs have the type of the ends, so min and max give rangeUnderflow and rangeOverflow, and required gives valueMissing for each empty end. As in Date Field, each field reports some empty segments as badInput, a limit that the input type cannot check as rangeUnderflow or rangeOverflow, and a date that unavailableDates matches as customError.
The end field is invalid when it is before the first end of the range, or before min. Its form input then gives rangeUnderflow, also for a zoned value. A field that shows a time compares the time too, so a time before the first time of the same day is invalid. A field that shows no time compares days. Two zoned ends compare by the moment, also when they are in two time zones.
Put the picker in a Field to show the errors of its validation. The picker is the one control of the Field, and a change of either end validates it. Each form input keeps the name of startName or endName, and the name of the Field is the key of its errors. The Field counts a leave only when the focus leaves both fields.
Show the range in the trigger
The text of the slots of DateRangePicker.Trigger is the range in the locale, or undefined while an end has 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
| Key | Action |
|---|---|
| Alt+Down in a field | Opens the popup. The focus goes to the day that has the tab stop. |
| Enter, Space | On the trigger, opens the popup. On a day, picks it. The second pick closes the popup, unless closeOnSelect is false. |
| Escape | Closes the popup and gives the focus back to the trigger. With the focus in the calendar, it also puts back the range from before the first press of a range in progress. |
| Tab | Moves the focus through the popup in the order of the page, after the trigger. |
| The keys of Date Field and Range Calendar | Do the same actions in the fields and in the calendar. |
API reference
DateRangePicker.Root
Groups the parts of the picker and holds its range. 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 fields and the calendar show, such as gregory or persian. The
default is the calendar of an end that is not ISO, else the calendar of the locale. | |
closeOnSelect | boolean | undefined | true | The press that gives the second end, or a drag, closes the popup. The user sets a time in a
field, so the default is true also for a range with a 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 | DateRangePickerRootValue<Value> | null | undefined | The range 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 range or open the popup. |
endName | string | undefined | The name of the form input of the end field. | |
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 inputs, for a picker outside that form. | |
granularity | DateRangePickerRootGranularity | undefined | The last unit that the fields show. With no value, it also gives the kind of a new end: day a
date, and a time unit a date with a time. | |
hideTimeZone | boolean | undefined | false | The fields show 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 end. The calendar disables a later day, and a later end makes its field invalid. | |
min | DateValue | undefined | The earliest end. The calendar disables an earlier day, and an earlier end makes its field invalid. An end before the first end makes the end field invalid. | |
modal | boolean | "trap-focus" | undefined | false | The modal state of the open popup, as for Popover.Root. |
modelValue | DateRangePickerRootValue<Value> | null | undefined | The first day and the last day of the range: each a Temporal.PlainDate, PlainDateTime or
ZonedDateTime, or null while it has no value. null is [null, null]. A new end has the
kind, the calendar, the time and the zone of an end, else of defaultValue, else of the last
end. | |
open | boolean | undefined | The popup is open. v-model:open binds it. | |
readonly | boolean | undefined | false | The user cannot change the range or open the popup. The fields stay in the tab order and in the form data. |
referenceDate | DateValue | undefined | Gives the kind, the calendar, the time zone and the hidden units of a first end, and the numbers of an empty segment for an arrow key. | |
required | boolean | undefined | false | The user must give both ends before a submit. |
startName | string | undefined | The name of the form input of the start field. | |
timeZone | string | undefined | The time zone in which the picker reads today. The default is the zone of a
Temporal.ZonedDateTime end, 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: DateRangePickerRootValue<Value>, details: DateRangePickerRootChangeEventDetails] | The user changes the range. An end is null while a segment of its field is empty.
details.cancel() keeps the range as it was. |
update:modelValue | [value: DateRangePickerRootValue<Value>] | 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: DateRangePickerRootOpenChangeEventDetails] | 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'. |
DateRangePicker.StartField
The field of the first day: DateField.Root with the start of the range. It takes the other
props of DateField.Root, such as id, and it has the selectors of that part. Its form input has
the name startName. 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: DateRangePickerStartFieldState | 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 end to a form. |
clear | () => void | Empties each segment. update:modelValue follows when the end had a value. |
DateRangePicker.EndField
The field of the last day: DateField.Root with the end of the range. It takes the other props
of DateField.Root, such as id, and it has the selectors of that part. Its form input has the
name endName. An end before the start makes it invalid. 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: DateRangePickerEndFieldState | 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 end to a form. |
clear | () => void | Empties each segment. update:modelValue follows when the end had a value. |
DateRangePicker.Trigger
A button that opens the popup: Popover.Trigger of the picker. The text of its slots is the
range in the locale, or undefined while an end has 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: DateRangePickerTriggerStatetext: string | undefined | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: DateRangePickerTriggerStatetext: 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 a 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. |
DateRangePicker.Positioner
Places the popup at the two fields: 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 box around the first start field and the first end field, else the one field, else the trigger. |
Slots
| Slot | Slot props | Description |
|---|---|---|
default | state: DateRangePickerPositionerState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: DateRangePickerPositionerState | 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. |
DateRangePicker.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 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: DateRangePickerPopupState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: DateRangePickerPopupState | 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. |
DateRangePicker.Calendar
The calendar of the picker: RangeCalendar.Root with the range of the picker. It takes the other
props and events of RangeCalendar.Root, such as minDays and monthChange, and it has the
selectors of that part. The press that gives the second end, or a drag, closes the popup when
closeOnSelect of the root allows it.
Renders a <div> element.
Slots
| Slot | Slot props | Description |
|---|---|---|
default | state: DateRangePickerCalendarState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: DateRangePickerCalendarState | 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. |
DateRangePicker.Root.ChangeEventReason
The reason of valueChange: day-press and drag come from the calendar, keyboard from the calendar or a field, and the other reasons from a field.
'day-press' | 'drag' | 'keyboard' | 'input-change' | 'input-clear' | 'input-paste' | 'clear-press'
DateRangePicker.Root.OpenChangeEventReason
The reason of openChange: Alt+Down in a field gives trigger-press, and a pick or a drag 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 Range Picker. A person types the first day and the last day of a range in two fields, or picks them in a calendar in a popup. The picker gives two Temporal values 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.