Range Calendar
A calendar that picks the first day and the last day of a range.
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
<script setup lang="ts">
import { Calendar } from '@vase-ui/vue/calendar';
import { RangeCalendar } from '@vase-ui/vue/range-calendar';
import styles from '../../_index.module.css';
const defaultValue: [Temporal.PlainDate, Temporal.PlainDate] = [
Temporal.PlainDate.from('2026-11-10'),
Temporal.PlainDate.from('2026-11-14'),
];
</script>
<template>
<RangeCalendar.Root
:class="styles.Root"
aria-label="Trip dates"
locale="en-US"
:default-value="defaultValue"
>
<Calendar.PreviousButton :class="[styles.Navigation, styles.Previous]">
<svg
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M10 3 5 8l5 5" />
</svg>
</Calendar.PreviousButton>
<Calendar.NextButton :class="[styles.Navigation, styles.Next]">
<svg
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m6 3 5 5-5 5" />
</svg>
</Calendar.NextButton>
<Calendar.Months :class="styles.Months">
<template #month="{ month }">
<Calendar.Month :month="month" :class="styles.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>
</RangeCalendar.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
display: inline-block;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
background-color: white;
color: oklch(14.5% 0 0deg);
font-family: inherit;
font-size: 0.875rem;
line-height: 1.25rem;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
background-color: oklch(14.5% 0 0deg);
color: white;
}
}
.Months {
display: flex;
gap: 1.5rem;
}
.Month {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.Caption {
font-weight: 500;
line-height: 2rem;
text-align: center;
}
.Navigation {
position: absolute;
top: 0.75rem;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
width: 2rem;
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
background-color: transparent;
color: inherit;
cursor: pointer;
@media (hover: hover) {
&: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']) {
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;
}
}
}
.Previous {
inset-inline-start: 0.75rem;
}
.Next {
inset-inline-end: 0.75rem;
}
.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;
}
}
}
.Footer {
margin-top: 0.5rem;
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 { RangeCalendar } from '@vase-ui/vue/range-calendar';
const defaultValue: [Temporal.PlainDate, Temporal.PlainDate] = [
Temporal.PlainDate.from('2026-11-10'),
Temporal.PlainDate.from('2026-11-14'),
];
</script>
<template>
<RangeCalendar.Root
class="relative box-border inline-block rounded-lg border border-neutral-200 bg-white p-3 text-sm text-neutral-950 dark:border-neutral-800 dark:bg-neutral-950 dark:text-white"
aria-label="Trip dates"
locale="en-US"
:default-value="defaultValue"
>
<Calendar.PreviousButton
class="absolute top-3 box-border flex size-8 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent p-0 text-inherit 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 start-3"
>
<svg
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M10 3 5 8l5 5" />
</svg>
</Calendar.PreviousButton>
<Calendar.NextButton
class="absolute top-3 box-border flex size-8 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent p-0 text-inherit 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 end-3"
>
<svg
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m6 3 5 5-5 5" />
</svg>
</Calendar.NextButton>
<Calendar.Months class="flex gap-6">
<template #month="{ month }">
<Calendar.Month :month="month" class="flex flex-col gap-2">
<Calendar.Caption class="text-center leading-8 font-medium" />
<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="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"
/>
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</RangeCalendar.Root>
</template>Usage guidelines
- Load
Temporalfirst: An engine with noTemporalneeds a polyfill, and TypeScript before 6.0 needsskipLibCheck. Dates and times gives the steps. - Name the range calendar: With no name of your own, the root has the name of the months that it shows. Give the root an
aria-label, or anaria-labelledbythat names a heading, to say what the range is for.
Anatomy
Import the component and assemble its parts:
<script setup lang="ts">
import { Calendar } from '@vase-ui/vue/calendar';
import { RangeCalendar } from '@vase-ui/vue/range-calendar';
</script>
<template>
<RangeCalendar.Root>
<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>
<Calendar.Footer />
</RangeCalendar.Root>
</template>Examples
Pick a range
RangeCalendar.Root holds the parts of Calendar and shows days only: Calendar.ViewTrigger is disabled in it, and Calendar.MonthGrid and Calendar.YearGrid render nothing.
- The first press on a day starts a range in progress. The root has
data-selectinguntil the range ends. - The second press ends the range, with the two days in the order of the calendar. A press on the first day again gives a range of one day.
- A press after a complete range starts a new range. A press that gives a range that is not valid also starts a new range at the pressed day.
- A range is not valid when it has fewer days than
minDaysor more days thanmaxDays. With noallowNonContiguousRanges, a range that crosses a disabled or unavailable day is not valid. With it, the crossed day getsdata-range-middleand is not selected. - A drag with a mouse, a pen or a finger from one day to another gives the range in one
valueChange. When that range is not valid, it ends at the last day that gives a valid range. A press and a release on one day is a press. Escape stops a drag, and the release after it changes nothing. - While a range is in progress, the days show the range of a press on the day under a mouse or a pen, or on the focused day.
Calendar.Day and Calendar.DayButton have data-range-start, data-range-end and data-range-middle. A range of one day has the first two. The day buttons have touch-action: none, so that a finger can drag over the days. To let the page scroll from a day, give the button a style with another touch-action.
Minimum and maximum days
minDays and maxDays give the least and the greatest number of days of a range. Both ends count, so Monday to Wednesday is 3 days. Calendar.Footer is a live region for a message below the calendar.
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
<script setup lang="ts">
import { computed, shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import { RangeCalendar } from '@vase-ui/vue/range-calendar';
import styles from '../../_index.module.css';
const value = shallowRef<RangeCalendar.Root.Value>([
Temporal.PlainDate.from('2026-11-09'),
Temporal.PlainDate.from('2026-11-12'),
]);
const formatter = new Intl.DateTimeFormat('en-US', {
month: 'short',
day: 'numeric',
timeZone: 'UTC',
});
function format(date: Temporal.PlainDate) {
return formatter.format(Date.UTC(date.year, date.month - 1, date.day));
}
const summary = computed(() => {
const [start, end] = value.value;
if (!start) {
return 'Pick 3 to 7 days.';
}
return end
? `${format(start)} to ${format(end)}, ${end.since(start).days + 1} days.`
: `From ${format(start)}. Pick the last day.`;
});
</script>
<template>
<RangeCalendar.Root
:class="styles.Root"
v-model="value"
aria-label="Rental dates"
:min-days="3"
:max-days="7"
locale="en-US"
>
<Calendar.PreviousButton :class="[styles.Navigation, styles.Previous]">
<svg
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M10 3 5 8l5 5" />
</svg>
</Calendar.PreviousButton>
<Calendar.NextButton :class="[styles.Navigation, styles.Next]">
<svg
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m6 3 5 5-5 5" />
</svg>
</Calendar.NextButton>
<Calendar.Months :class="styles.Months">
<template #month="{ month }">
<Calendar.Month :month="month" :class="styles.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>
<Calendar.Footer :class="styles.Footer">{{ summary }}</Calendar.Footer>
</RangeCalendar.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
display: inline-block;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
background-color: white;
color: oklch(14.5% 0 0deg);
font-family: inherit;
font-size: 0.875rem;
line-height: 1.25rem;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
background-color: oklch(14.5% 0 0deg);
color: white;
}
}
.Months {
display: flex;
gap: 1.5rem;
}
.Month {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.Caption {
font-weight: 500;
line-height: 2rem;
text-align: center;
}
.Navigation {
position: absolute;
top: 0.75rem;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
width: 2rem;
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
background-color: transparent;
color: inherit;
cursor: pointer;
@media (hover: hover) {
&: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']) {
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;
}
}
}
.Previous {
inset-inline-start: 0.75rem;
}
.Next {
inset-inline-end: 0.75rem;
}
.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;
}
}
}
.Footer {
margin-top: 0.5rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}<script setup lang="ts">
import { computed, shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import { RangeCalendar } from '@vase-ui/vue/range-calendar';
const value = shallowRef<RangeCalendar.Root.Value>([
Temporal.PlainDate.from('2026-11-09'),
Temporal.PlainDate.from('2026-11-12'),
]);
const formatter = new Intl.DateTimeFormat('en-US', {
month: 'short',
day: 'numeric',
timeZone: 'UTC',
});
function format(date: Temporal.PlainDate) {
return formatter.format(Date.UTC(date.year, date.month - 1, date.day));
}
const summary = computed(() => {
const [start, end] = value.value;
if (!start) {
return 'Pick 3 to 7 days.';
}
return end
? `${format(start)} to ${format(end)}, ${end.since(start).days + 1} days.`
: `From ${format(start)}. Pick the last day.`;
});
</script>
<template>
<RangeCalendar.Root
class="relative box-border inline-block rounded-lg border border-neutral-200 bg-white p-3 text-sm text-neutral-950 dark:border-neutral-800 dark:bg-neutral-950 dark:text-white"
v-model="value"
aria-label="Rental dates"
:min-days="3"
:max-days="7"
locale="en-US"
>
<Calendar.PreviousButton
class="absolute top-3 box-border flex size-8 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent p-0 text-inherit 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 start-3"
>
<svg
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M10 3 5 8l5 5" />
</svg>
</Calendar.PreviousButton>
<Calendar.NextButton
class="absolute top-3 box-border flex size-8 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent p-0 text-inherit 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 end-3"
>
<svg
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m6 3 5 5-5 5" />
</svg>
</Calendar.NextButton>
<Calendar.Months class="flex gap-6">
<template #month="{ month }">
<Calendar.Month :month="month" class="flex flex-col gap-2">
<Calendar.Caption class="text-center leading-8 font-medium" />
<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="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"
/>
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
<Calendar.Footer class="mt-2 text-neutral-600 dark:text-neutral-400">{{
summary
}}</Calendar.Footer>
</RangeCalendar.Root>
</template>Two months
numberOfMonths shows more than one month. With pagedNavigation, the navigation buttons move by that number of months. A range can start in one month and end in another.
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
<script setup lang="ts">
import { Calendar } from '@vase-ui/vue/calendar';
import { RangeCalendar } from '@vase-ui/vue/range-calendar';
import styles from '../../_index.module.css';
const defaultValue: [Temporal.PlainDate, Temporal.PlainDate] = [
Temporal.PlainDate.from('2026-11-24'),
Temporal.PlainDate.from('2026-12-03'),
];
</script>
<template>
<RangeCalendar.Root
:class="styles.Root"
aria-label="Conference dates"
:number-of-months="2"
paged-navigation
locale="en-US"
:default-value="defaultValue"
>
<Calendar.PreviousButton :class="[styles.Navigation, styles.Previous]">
<svg
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M10 3 5 8l5 5" />
</svg>
</Calendar.PreviousButton>
<Calendar.NextButton :class="[styles.Navigation, styles.Next]">
<svg
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m6 3 5 5-5 5" />
</svg>
</Calendar.NextButton>
<Calendar.Months :class="styles.Months">
<template #month="{ month }">
<Calendar.Month :month="month" :class="styles.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>
</RangeCalendar.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
display: inline-block;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
background-color: white;
color: oklch(14.5% 0 0deg);
font-family: inherit;
font-size: 0.875rem;
line-height: 1.25rem;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
background-color: oklch(14.5% 0 0deg);
color: white;
}
}
.Months {
display: flex;
gap: 1.5rem;
}
.Month {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.Caption {
font-weight: 500;
line-height: 2rem;
text-align: center;
}
.Navigation {
position: absolute;
top: 0.75rem;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
width: 2rem;
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
background-color: transparent;
color: inherit;
cursor: pointer;
@media (hover: hover) {
&: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']) {
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;
}
}
}
.Previous {
inset-inline-start: 0.75rem;
}
.Next {
inset-inline-end: 0.75rem;
}
.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;
}
}
}
.Footer {
margin-top: 0.5rem;
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 { RangeCalendar } from '@vase-ui/vue/range-calendar';
const defaultValue: [Temporal.PlainDate, Temporal.PlainDate] = [
Temporal.PlainDate.from('2026-11-24'),
Temporal.PlainDate.from('2026-12-03'),
];
</script>
<template>
<RangeCalendar.Root
class="relative box-border inline-block rounded-lg border border-neutral-200 bg-white p-3 text-sm text-neutral-950 dark:border-neutral-800 dark:bg-neutral-950 dark:text-white"
aria-label="Conference dates"
:number-of-months="2"
paged-navigation
locale="en-US"
:default-value="defaultValue"
>
<Calendar.PreviousButton
class="absolute top-3 box-border flex size-8 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent p-0 text-inherit 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 start-3"
>
<svg
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M10 3 5 8l5 5" />
</svg>
</Calendar.PreviousButton>
<Calendar.NextButton
class="absolute top-3 box-border flex size-8 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent p-0 text-inherit 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 end-3"
>
<svg
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m6 3 5 5-5 5" />
</svg>
</Calendar.NextButton>
<Calendar.Months class="flex gap-6">
<template #month="{ month }">
<Calendar.Month :month="month" class="flex flex-col gap-2">
<Calendar.Caption class="text-center leading-8 font-medium" />
<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="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"
/>
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</RangeCalendar.Root>
</template>Render on the server
The server HTML has the grid, the range, one tab stop and the touch style of each day. The rules of Calendar apply: give locale, and give defaultMonth or today for a month in the server HTML.
Keyboard
| Key | Action |
|---|---|
| Tab | Moves the focus to the tab stop of the grid. The tab stop is the focused day, else the first selected day, else today, else the first day that can take the focus. |
| Left Arrow, Right Arrow | Moves the focus to the day before or after. The two keys swap in a right-to-left document. |
| Up Arrow, Down Arrow | Moves the focus to the same day of the week before or after. |
| Home, End | Moves the focus to the first or the last day of the week. |
| Page Up, Page Down | Moves the focus to the same day of the month before or after, or to the last day of a shorter month. |
| Shift+Page Up, Shift+Page Down | Moves the focus to the same day a year before or after. |
| Enter, Space | Picks the day. The first press starts the range, and the second press ends it. |
| Shift+Left, Shift+Right | Moves the focus one day, and makes the range from the first day to that day. The first day is the start of a range in progress, else the day that had the focus before the first key. |
| Shift+Up, Shift+Down | Moves the focus one week, and makes the range in the same way. |
| Escape | Stops a drag. Else, puts back the range from before the first press of a range in progress. It works with the focus on each element of the calendar. The calendar prevents the key only in these two cases. |
API reference
RangeCalendar.Root
Groups the parts of Calendar for a range of days.
Renders a <div> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
allowNonContiguousRanges | boolean | undefined | false | A range can cross a day that is disabled or unavailable. That day is then in the range and not selected. Without it, a drag stops before such a day. |
autofocus | boolean | undefined | false | The day that has the tab stop takes the focus at the mount. |
broadcastCalendar | boolean | undefined | false | The grid shows the broadcast calendar: weeks from Monday, and a month of the 4 or 5 weeks from the Monday of the week that holds its first day. It needs the Gregorian calendar. |
calendar | string | undefined | The calendar of the grid, such as gregory or persian. The default is the calendar of a
value that is not ISO, else gregory. The value keeps its own calendar. | |
defaultFocusedDate | Temporal.PlainDate | null | undefined | The focused day at the mount of an uncontrolled focused day. | |
defaultMonth | Temporal.PlainYearMonth | undefined | The first month of the page at the mount of an uncontrolled month. With none, the page holds
the focused day, else the first value, else today, and keeps to min and max. | |
defaultValue | readonly [Value | null, Value | null] | undefined | The range at the mount of an uncontrolled calendar. It also gives the kind of a new end. | |
disabled | boolean | undefined | false | The user cannot change the calendar, and no part of it takes the focus. |
disabledDates | DateMatcher | undefined | The days that take no focus and no selection. | |
firstDayOfWeek | DayOfWeek | undefined | The first day of the week, from 1 for Monday to 7 for Sunday. The default is the first
day in the region of the locale, as CLDR gives it: 7 for en-US, 1 for de-DE. A locale
with no region takes its likely region. The broadcast calendar always starts on Monday. | |
firstWeekContainsDate | DayOfWeek | undefined | The day of January that is always in week 1, from 1 to 7. The default is 4 for weeks
that start on Monday, which gives the ISO 8601 week number, and 1 for weeks that start on
another day. | |
fixedWeeks | boolean | undefined | false | Each month has six weeks, and five weeks with broadcastCalendar, so the grid keeps its height. |
focusedDate | Temporal.PlainDate | null | undefined | The day that the user focused last. It has the tab stop. null is no such day.
v-model:focusedDate binds it. A new day that the page does not show moves the page. | |
hiddenDates | DateMatcher | undefined | The days that have no button. | |
invalid | boolean | undefined | false | The value of the calendar is not valid. |
locale | Intl.LocalesArgument | The locale of each text. With none, the nearest LocaleProvider, else en-US. | |
max | DateValue | undefined | The last day that the user can select. A later day is disabled. It wins over min. | |
maxDays | number | undefined | The greatest number of days of a range. The two ends count. A press that makes a longer range starts a new range, and a drag stops at this number. | |
min | DateValue | undefined | The first day that the user can select. An earlier day is disabled. | |
minDays | number | undefined | The least number of days of a range. The two ends count. A press that makes a shorter range starts a new range. | |
modelValue | readonly [Value | null, Value | null] | undefined | The first and the last day of the range. v-model binds it. [start, null] is a range in
progress, and [null, null] is no range. A new end has the kind, the time, the zone and the
calendar of the end that it replaces, else of the other end, else of defaultValue, else of the
last end. With none of them, it is a Temporal.PlainDate. | |
modifiers | Record<string, DateMatcher> | undefined | A day that a rule matches has a data-* attribute in kebab case with the name of the rule, and
state.modifiers[name] is true. The names of the day attributes are reserved. | |
month | Temporal.PlainYearMonth | undefined | The first month of the page. v-model:month binds it. The root shows it as it is, also when
it is out of min and max. | |
numberOfMonths | number | undefined | 1 | The number of months that the page shows. |
pagedNavigation | boolean | undefined | false | The navigation buttons move by numberOfMonths months, and not by one month. |
readonly | boolean | undefined | false | The user cannot select a day. The days take the focus, and the buttons move the page. |
showOutsideDays | boolean | undefined | The days of the months around a month have a button. The default is false, and true with
broadcastCalendar. Two months of the page that share a day show it one time. | |
today | DateValue | undefined | The day that is today. With none, the root reads the clock after the mount, in the zone of a zoned value. The server HTML then has no today. A server that knows the day of the visitor gives it here. | |
unavailableDates | DateMatcher | undefined | The days that take the focus and no selection. | |
visibleDuration | CalendarVisibleDuration | undefined | One page of whole weeks, { weeks: 2 }, or one row of days, { days: 5 }, in place of a
month. The navigation buttons move by this duration. | |
as | keyof HTMLElementTagNameMap | Component | GenericComponent | undefined | A tag or a component that the part renders in place of its own element, with the same
attributes and content. The element slot wins over it. |
Slots
| Slot | Slot props | Description |
|---|---|---|
default | state: RangeCalendarRootState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: RangeCalendarRootState | Renders your element in place of the element of the part. Bind props with v-bind and elementRef with :ref. |
Events
| Event | Arguments | Description |
|---|---|---|
valueChange | [value: RangeCalendarRootValue<Value>, details: RangeCalendarRootChangeEventDetails] | The user changes the range. details.cancel() keeps the range as it is. |
update:modelValue | [value: RangeCalendarRootValue<Value>] | Comes after valueChange, unless a listener cancels the change. v-model uses it. |
monthChange | [month: Temporal.PlainYearMonth, details: RangeCalendarRootChangeEventDetails] | The user moves the page. details.cancel() keeps the page. |
update:month | [month: Temporal.PlainYearMonth] | Comes after monthChange, and for a move with no user event. v-model:month uses it. |
focusedDateChange | [date: Temporal.PlainDate, details: RangeCalendarRootChangeEventDetails] | A day gets the focus, or a key moves it. details.cancel() keeps the focused day. |
update:focusedDate | [date: Temporal.PlainDate] | Comes after focusedDateChange, and for a move with no user event. v-model:focusedDate uses it. |
Exposed
| Member | Type | Description |
|---|---|---|
element | HTMLElement | null | The element of the part, or null while it is not mounted. |
focus | (date?: DateValue | undefined) => void | Focuses the day that has the tab stop. With date, shows its page and focuses it, when it can take the focus. |
Selectors
| Selector | Description |
|---|---|
[data-selecting] | The user picked the first day and not the last day, or drags a range. |
[data-navigation-direction] | The side of the last move of the page: previous, next or none. |
[data-disabled] | The calendar is disabled. |
[data-readonly] | The calendar is read-only. |
[data-invalid] | The value of the calendar is not valid. |
[data-empty] | No day is selected. |
RangeCalendar.Root.ChangeEventReason
The reason of the details of a change event: month-change is a navigation button or a select, and none is a focus.
'day-press' | 'drag' | 'keyboard' | 'month-change' | 'none'
Differences from Base UI
Base UI has no Range Calendar. A person picks the first day and the last day of a range on one grid, with a press, a drag or the keyboard. The root holds the parts of Calendar.
- https://www.w3.org/WAI/ARIA/apg/patterns/grid/
- https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/examples/datepicker-dialog/
The handbook gives the differences that all components share: Styling, Animation, Composition, Customization, Forms and TypeScript.