Calendar
A grid of days, months or years in which a person selects a day or a month.
<script setup lang="ts">
import { Calendar } from '@vase-ui/vue/calendar';
import styles from '../../_index.module.css';
</script>
<template>
<Calendar.Root locale="en-US" :class="[styles.Root, styles.SixWeeks]">
<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>
</Calendar.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
width: 18rem;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(14.5% 0 0deg);
background-color: white;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
color: white;
background-color: oklch(14.5% 0 0deg);
}
}
/* The month comes after the mount, so the root keeps the room of a caption and six weeks. */
.SixWeeks {
min-height: 19.75rem;
}
.WithWeekNumbers {
width: 20.25rem;
}
.WithMonths {
width: fit-content;
max-width: 100%;
}
.Nav {
position: absolute;
top: 0.75rem;
right: 0.75rem;
display: flex;
gap: 0.25rem;
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Selects {
display: flex;
gap: 0.25rem;
margin-bottom: 0.5rem;
}
.Select {
box-sizing: border-box;
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 1px solid oklch(55.6% 0 0deg);
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
@media (prefers-color-scheme: dark) {
border-color: oklch(70.8% 0 0deg);
color-scheme: dark;
}
&: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;
}
}
}
.Button,
.Title {
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
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']) {
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;
}
}
}
.Button {
width: 2rem;
}
.Title {
padding: 0 0.75rem;
font-weight: 600;
}
.Months {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
}
.Month {
width: 16rem;
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday,
.WeekNumber {
font-size: 0.75rem;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Weekday {
padding: 0.25rem 0;
font-weight: 500;
}
.WeekNumber {
padding: 0;
font-weight: 400;
font-variant-numeric: tabular-nums;
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.Cell {
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;
@media (hover: hover) {
&:hover:not([data-selected], [aria-selected='true'], :disabled, [data-unavailable]) {
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);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
&[data-unavailable] {
text-decoration: line-through;
cursor: default;
}
&[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;
}
.Holiday[data-holiday] {
position: relative;
&::after {
content: '';
position: absolute;
bottom: 0.25rem;
left: 50%;
width: 0.25rem;
height: 0.25rem;
border-radius: 50%;
background-color: currentColor;
translate: -50% 0;
}
}
.Rows {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.Row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.25rem;
}
.Cell {
height: 2.5rem;
}
.Footer {
margin-top: 0.5rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Pages {
--page-direction: 1;
position: relative;
&[data-navigation-direction='previous'] {
--page-direction: -1;
}
}
.Page {
position: relative;
}
/* The demo gives `<Transition>` the name `calendar-page`. */
.PageGrid:global(.calendar-page-enter-active),
.PageGrid:global(.calendar-page-leave-active) {
transition:
opacity 200ms ease-out,
translate 200ms ease-out;
@media (prefers-reduced-motion: reduce) {
transition: none;
}
}
.PageGrid:global(.calendar-page-enter-from) {
opacity: 0;
translate: calc(0.5rem * var(--page-direction)) 0;
}
/* The grid that leaves stays where it is, above the grid that enters. */
.PageGrid:global(.calendar-page-leave-active) {
position: absolute;
right: 0;
left: 0;
}
.PageGrid:global(.calendar-page-leave-to) {
opacity: 0;
translate: calc(-0.5rem * var(--page-direction)) 0;
}<script setup lang="ts">
import { Calendar } from '@vase-ui/vue/calendar';
</script>
<template>
<Calendar.Root
locale="en-US"
class="relative box-border min-h-79 w-72 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"
>
<div class="absolute top-3 right-3 flex gap-1">
<Calendar.PreviousButton
class="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"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton
class="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"
>›</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 leading-5 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="box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:not-data-unavailable: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 data-unavailable:cursor-default data-unavailable:line-through disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:not-data-unavailable:bg-neutral-800 dark:focus-visible:outline-white dark:data-outside-month:not-data-selected:text-neutral-400 dark:data-selected:bg-white dark:data-selected:text-neutral-950"
/>
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</Calendar.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 calendar: With no name of your own, the root has the name of the page that it shows, such as
November 2026. Give the root anaria-label, or anaria-labelledbythat names a heading, to say what the date is for. - Describe the view trigger: The name of
Calendar.ViewTriggeris the page that it shows, such as2026. Give it anaria-descriptionthat says what a press does.
Anatomy
Import the component and assemble its parts:
<script setup lang="ts">
import { Calendar } from '@vase-ui/vue/calendar';
</script>
<template>
<Calendar.Root>
<Calendar.PreviousButton />
<Calendar.ViewTrigger />
<Calendar.NextButton />
<Calendar.Months>
<template #month="{ month }">
<Calendar.Month :month="month">
<Calendar.Caption />
<Calendar.MonthSelect />
<Calendar.YearSelect />
<Calendar.Grid>
<Calendar.GridHeader>
<Calendar.GridHeaderRow>
<Calendar.WeekNumberHeader />
<template #weekday="{ weekday }">
<Calendar.Weekday :weekday="weekday" />
</template>
</Calendar.GridHeaderRow>
</Calendar.GridHeader>
<Calendar.GridBody>
<template #week="{ week }">
<Calendar.Week :week="week">
<Calendar.WeekNumber :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.MonthGrid>
<template #row="{ months }">
<Calendar.MonthGridRow>
<Calendar.MonthCell v-for="month in months" :key="month.toString()" :month="month" />
</Calendar.MonthGridRow>
</template>
</Calendar.MonthGrid>
<Calendar.YearGrid>
<template #row="{ years }">
<Calendar.YearGridRow>
<Calendar.YearCell v-for="year in years" :key="year.toString()" :year="year" />
</Calendar.YearGridRow>
</template>
</Calendar.YearGrid>
<Calendar.Footer />
</Calendar.Root>
</template>Examples
Months and years
Calendar.ViewTrigger shows the grid of years, or the grid of months with view="month". A second press shows the days again. A press on a year shows the months of that year, and a press on a month shows its days.
<script setup lang="ts">
import { Calendar } from '@vase-ui/vue/calendar';
import styles from '../../_index.module.css';
</script>
<template>
<Calendar.Root locale="en-US" :class="[styles.Root, styles.SixWeeks]">
<div :class="styles.Header">
<Calendar.PreviousButton :class="styles.Button">‹</Calendar.PreviousButton>
<Calendar.ViewTrigger
aria-description="Shows the years, or the days again"
:class="styles.Title"
/>
<Calendar.NextButton :class="styles.Button">›</Calendar.NextButton>
</div>
<Calendar.Months>
<template #month="{ month }">
<Calendar.Month :month="month">
<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.MonthGrid :class="styles.Rows">
<template #row="{ months }">
<Calendar.MonthGridRow :class="styles.Row">
<Calendar.MonthCell
v-for="month in months"
:key="month.toString()"
:month="month"
:class="styles.Cell"
/>
</Calendar.MonthGridRow>
</template>
</Calendar.MonthGrid>
<Calendar.YearGrid :class="styles.Rows">
<template #row="{ years }">
<Calendar.YearGridRow :class="styles.Row">
<Calendar.YearCell
v-for="year in years"
:key="year.toString()"
:year="year"
:class="styles.Cell"
/>
</Calendar.YearGridRow>
</template>
</Calendar.YearGrid>
</Calendar.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
width: 18rem;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(14.5% 0 0deg);
background-color: white;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
color: white;
background-color: oklch(14.5% 0 0deg);
}
}
/* The month comes after the mount, so the root keeps the room of a caption and six weeks. */
.SixWeeks {
min-height: 19.75rem;
}
.WithWeekNumbers {
width: 20.25rem;
}
.WithMonths {
width: fit-content;
max-width: 100%;
}
.Nav {
position: absolute;
top: 0.75rem;
right: 0.75rem;
display: flex;
gap: 0.25rem;
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Selects {
display: flex;
gap: 0.25rem;
margin-bottom: 0.5rem;
}
.Select {
box-sizing: border-box;
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 1px solid oklch(55.6% 0 0deg);
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
@media (prefers-color-scheme: dark) {
border-color: oklch(70.8% 0 0deg);
color-scheme: dark;
}
&: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;
}
}
}
.Button,
.Title {
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
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']) {
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;
}
}
}
.Button {
width: 2rem;
}
.Title {
padding: 0 0.75rem;
font-weight: 600;
}
.Months {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
}
.Month {
width: 16rem;
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday,
.WeekNumber {
font-size: 0.75rem;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Weekday {
padding: 0.25rem 0;
font-weight: 500;
}
.WeekNumber {
padding: 0;
font-weight: 400;
font-variant-numeric: tabular-nums;
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.Cell {
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;
@media (hover: hover) {
&:hover:not([data-selected], [aria-selected='true'], :disabled, [data-unavailable]) {
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);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
&[data-unavailable] {
text-decoration: line-through;
cursor: default;
}
&[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;
}
.Holiday[data-holiday] {
position: relative;
&::after {
content: '';
position: absolute;
bottom: 0.25rem;
left: 50%;
width: 0.25rem;
height: 0.25rem;
border-radius: 50%;
background-color: currentColor;
translate: -50% 0;
}
}
.Rows {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.Row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.25rem;
}
.Cell {
height: 2.5rem;
}
.Footer {
margin-top: 0.5rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Pages {
--page-direction: 1;
position: relative;
&[data-navigation-direction='previous'] {
--page-direction: -1;
}
}
.Page {
position: relative;
}
/* The demo gives `<Transition>` the name `calendar-page`. */
.PageGrid:global(.calendar-page-enter-active),
.PageGrid:global(.calendar-page-leave-active) {
transition:
opacity 200ms ease-out,
translate 200ms ease-out;
@media (prefers-reduced-motion: reduce) {
transition: none;
}
}
.PageGrid:global(.calendar-page-enter-from) {
opacity: 0;
translate: calc(0.5rem * var(--page-direction)) 0;
}
/* The grid that leaves stays where it is, above the grid that enters. */
.PageGrid:global(.calendar-page-leave-active) {
position: absolute;
right: 0;
left: 0;
}
.PageGrid:global(.calendar-page-leave-to) {
opacity: 0;
translate: calc(-0.5rem * var(--page-direction)) 0;
}<script setup lang="ts">
import { Calendar } from '@vase-ui/vue/calendar';
</script>
<template>
<Calendar.Root
locale="en-US"
class="relative box-border min-h-79 w-72 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"
>
<div class="mb-2 flex items-center justify-between">
<Calendar.PreviousButton
class="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"
>‹</Calendar.PreviousButton
>
<Calendar.ViewTrigger
aria-description="Shows the years, or the days again"
class="h-8 cursor-pointer rounded-md px-3 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"
/>
<Calendar.NextButton
class="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"
>›</Calendar.NextButton
>
</div>
<Calendar.Months>
<template #month="{ month }">
<Calendar.Month :month="month">
<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 leading-5 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="box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:not-data-unavailable: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 data-unavailable:cursor-default data-unavailable:line-through disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:not-data-unavailable:bg-neutral-800 dark:focus-visible:outline-white dark:data-outside-month:not-data-selected:text-neutral-400 dark:data-selected:bg-white dark:data-selected:text-neutral-950"
/>
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
<Calendar.MonthGrid class="flex flex-col gap-1">
<template #row="{ months }">
<Calendar.MonthGridRow class="grid grid-cols-3 gap-1">
<Calendar.MonthCell
v-for="month in months"
:key="month.toString()"
:month="month"
class="box-border h-10 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 aria-selected:bg-neutral-950 aria-selected:text-white disabled:cursor-default disabled:opacity-40 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"
/>
</Calendar.MonthGridRow>
</template>
</Calendar.MonthGrid>
<Calendar.YearGrid class="flex flex-col gap-1">
<template #row="{ years }">
<Calendar.YearGridRow class="grid grid-cols-3 gap-1">
<Calendar.YearCell
v-for="year in years"
:key="year.toString()"
:year="year"
class="box-border h-10 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 aria-selected:bg-neutral-950 aria-selected:text-white disabled:cursor-default disabled:opacity-40 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"
/>
</Calendar.YearGridRow>
</template>
</Calendar.YearGrid>
</Calendar.Root>
</template>In the grid of months, the navigation buttons move one year. In the grid of years, they move one page of visibleYears years. With the default 12 years, the page of 2026 has the years from 2016 to 2027.
Month picker
A value that is a Temporal.PlainYearMonth makes a month picker. It shows the grid of months and no days, and a press on a month selects it. With multiple, a press adds or removes a month, and minDays and maxDays count months.
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import styles from '../../_index.module.css';
const selected = shallowRef<Temporal.PlainYearMonth | null>(
Temporal.PlainYearMonth.from('2026-11'),
);
</script>
<template>
<Calendar.Root v-model="selected" locale="en-US" :class="styles.Root">
<div :class="styles.Header">
<Calendar.PreviousButton :class="styles.Button">‹</Calendar.PreviousButton>
<Calendar.ViewTrigger
aria-description="Shows the years, or the months again"
:class="styles.Title"
/>
<Calendar.NextButton :class="styles.Button">›</Calendar.NextButton>
</div>
<Calendar.MonthGrid :class="styles.Rows">
<template #row="{ months }">
<Calendar.MonthGridRow :class="styles.Row">
<Calendar.MonthCell
v-for="month in months"
:key="month.toString()"
:month="month"
:class="styles.Cell"
/>
</Calendar.MonthGridRow>
</template>
</Calendar.MonthGrid>
<Calendar.YearGrid :class="styles.Rows">
<template #row="{ years }">
<Calendar.YearGridRow :class="styles.Row">
<Calendar.YearCell
v-for="year in years"
:key="year.toString()"
:year="year"
:class="styles.Cell"
/>
</Calendar.YearGridRow>
</template>
</Calendar.YearGrid>
</Calendar.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
width: 18rem;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(14.5% 0 0deg);
background-color: white;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
color: white;
background-color: oklch(14.5% 0 0deg);
}
}
/* The month comes after the mount, so the root keeps the room of a caption and six weeks. */
.SixWeeks {
min-height: 19.75rem;
}
.WithWeekNumbers {
width: 20.25rem;
}
.WithMonths {
width: fit-content;
max-width: 100%;
}
.Nav {
position: absolute;
top: 0.75rem;
right: 0.75rem;
display: flex;
gap: 0.25rem;
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Selects {
display: flex;
gap: 0.25rem;
margin-bottom: 0.5rem;
}
.Select {
box-sizing: border-box;
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 1px solid oklch(55.6% 0 0deg);
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
@media (prefers-color-scheme: dark) {
border-color: oklch(70.8% 0 0deg);
color-scheme: dark;
}
&: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;
}
}
}
.Button,
.Title {
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
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']) {
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;
}
}
}
.Button {
width: 2rem;
}
.Title {
padding: 0 0.75rem;
font-weight: 600;
}
.Months {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
}
.Month {
width: 16rem;
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday,
.WeekNumber {
font-size: 0.75rem;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Weekday {
padding: 0.25rem 0;
font-weight: 500;
}
.WeekNumber {
padding: 0;
font-weight: 400;
font-variant-numeric: tabular-nums;
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.Cell {
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;
@media (hover: hover) {
&:hover:not([data-selected], [aria-selected='true'], :disabled, [data-unavailable]) {
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);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
&[data-unavailable] {
text-decoration: line-through;
cursor: default;
}
&[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;
}
.Holiday[data-holiday] {
position: relative;
&::after {
content: '';
position: absolute;
bottom: 0.25rem;
left: 50%;
width: 0.25rem;
height: 0.25rem;
border-radius: 50%;
background-color: currentColor;
translate: -50% 0;
}
}
.Rows {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.Row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.25rem;
}
.Cell {
height: 2.5rem;
}
.Footer {
margin-top: 0.5rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Pages {
--page-direction: 1;
position: relative;
&[data-navigation-direction='previous'] {
--page-direction: -1;
}
}
.Page {
position: relative;
}
/* The demo gives `<Transition>` the name `calendar-page`. */
.PageGrid:global(.calendar-page-enter-active),
.PageGrid:global(.calendar-page-leave-active) {
transition:
opacity 200ms ease-out,
translate 200ms ease-out;
@media (prefers-reduced-motion: reduce) {
transition: none;
}
}
.PageGrid:global(.calendar-page-enter-from) {
opacity: 0;
translate: calc(0.5rem * var(--page-direction)) 0;
}
/* The grid that leaves stays where it is, above the grid that enters. */
.PageGrid:global(.calendar-page-leave-active) {
position: absolute;
right: 0;
left: 0;
}
.PageGrid:global(.calendar-page-leave-to) {
opacity: 0;
translate: calc(-0.5rem * var(--page-direction)) 0;
}<script setup lang="ts">
import { shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
const selected = shallowRef<Temporal.PlainYearMonth | null>(
Temporal.PlainYearMonth.from('2026-11'),
);
</script>
<template>
<Calendar.Root
v-model="selected"
locale="en-US"
class="relative box-border w-72 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"
>
<div class="mb-2 flex items-center justify-between">
<Calendar.PreviousButton
class="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"
>‹</Calendar.PreviousButton
>
<Calendar.ViewTrigger
aria-description="Shows the years, or the months again"
class="h-8 cursor-pointer rounded-md px-3 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"
/>
<Calendar.NextButton
class="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"
>›</Calendar.NextButton
>
</div>
<Calendar.MonthGrid class="flex flex-col gap-1">
<template #row="{ months }">
<Calendar.MonthGridRow class="grid grid-cols-3 gap-1">
<Calendar.MonthCell
v-for="month in months"
:key="month.toString()"
:month="month"
class="box-border h-10 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 aria-selected:bg-neutral-950 aria-selected:text-white disabled:cursor-default disabled:opacity-40 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"
/>
</Calendar.MonthGridRow>
</template>
</Calendar.MonthGrid>
<Calendar.YearGrid class="flex flex-col gap-1">
<template #row="{ years }">
<Calendar.YearGridRow class="grid grid-cols-3 gap-1">
<Calendar.YearCell
v-for="year in years"
:key="year.toString()"
:year="year"
class="box-border h-10 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 aria-selected:bg-neutral-950 aria-selected:text-white disabled:cursor-default disabled:opacity-40 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"
/>
</Calendar.YearGridRow>
</template>
</Calendar.YearGrid>
</Calendar.Root>
</template>To start with no month, set the value to null and defaultValue to a Temporal.PlainYearMonth. The calendar stays a month picker when its value becomes empty.
Multiple days
With multiple, a person selects a list of days, and maxDays limits the list. This calendar takes at most three interview days, none before today. Calendar.Footer is a live region for a message below the calendar. Here it counts the days.
<script setup lang="ts">
import { onMounted, shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import styles from '../../_index.module.css';
// A server does not know the day of the reader, so the value comes after the mount.
const today = shallowRef<Temporal.PlainDate>();
onMounted(() => {
today.value = Temporal.Now.plainDateISO();
});
const days = shallowRef<Temporal.PlainDate[]>([]);
</script>
<template>
<Calendar.Root
v-model="days"
multiple
:max-days="3"
:min="today"
locale="en-US"
aria-label="Interview days"
:class="[styles.Root, styles.SixWeeks]"
>
<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>
<Calendar.Footer :class="styles.Footer">{{ days.length }} of 3 days selected.</Calendar.Footer>
</Calendar.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
width: 18rem;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(14.5% 0 0deg);
background-color: white;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
color: white;
background-color: oklch(14.5% 0 0deg);
}
}
/* The month comes after the mount, so the root keeps the room of a caption and six weeks. */
.SixWeeks {
min-height: 19.75rem;
}
.WithWeekNumbers {
width: 20.25rem;
}
.WithMonths {
width: fit-content;
max-width: 100%;
}
.Nav {
position: absolute;
top: 0.75rem;
right: 0.75rem;
display: flex;
gap: 0.25rem;
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Selects {
display: flex;
gap: 0.25rem;
margin-bottom: 0.5rem;
}
.Select {
box-sizing: border-box;
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 1px solid oklch(55.6% 0 0deg);
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
@media (prefers-color-scheme: dark) {
border-color: oklch(70.8% 0 0deg);
color-scheme: dark;
}
&: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;
}
}
}
.Button,
.Title {
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
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']) {
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;
}
}
}
.Button {
width: 2rem;
}
.Title {
padding: 0 0.75rem;
font-weight: 600;
}
.Months {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
}
.Month {
width: 16rem;
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday,
.WeekNumber {
font-size: 0.75rem;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Weekday {
padding: 0.25rem 0;
font-weight: 500;
}
.WeekNumber {
padding: 0;
font-weight: 400;
font-variant-numeric: tabular-nums;
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.Cell {
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;
@media (hover: hover) {
&:hover:not([data-selected], [aria-selected='true'], :disabled, [data-unavailable]) {
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);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
&[data-unavailable] {
text-decoration: line-through;
cursor: default;
}
&[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;
}
.Holiday[data-holiday] {
position: relative;
&::after {
content: '';
position: absolute;
bottom: 0.25rem;
left: 50%;
width: 0.25rem;
height: 0.25rem;
border-radius: 50%;
background-color: currentColor;
translate: -50% 0;
}
}
.Rows {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.Row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.25rem;
}
.Cell {
height: 2.5rem;
}
.Footer {
margin-top: 0.5rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Pages {
--page-direction: 1;
position: relative;
&[data-navigation-direction='previous'] {
--page-direction: -1;
}
}
.Page {
position: relative;
}
/* The demo gives `<Transition>` the name `calendar-page`. */
.PageGrid:global(.calendar-page-enter-active),
.PageGrid:global(.calendar-page-leave-active) {
transition:
opacity 200ms ease-out,
translate 200ms ease-out;
@media (prefers-reduced-motion: reduce) {
transition: none;
}
}
.PageGrid:global(.calendar-page-enter-from) {
opacity: 0;
translate: calc(0.5rem * var(--page-direction)) 0;
}
/* The grid that leaves stays where it is, above the grid that enters. */
.PageGrid:global(.calendar-page-leave-active) {
position: absolute;
right: 0;
left: 0;
}
.PageGrid:global(.calendar-page-leave-to) {
opacity: 0;
translate: calc(-0.5rem * var(--page-direction)) 0;
}<script setup lang="ts">
import { onMounted, shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
// A server does not know the day of the reader, so the value comes after the mount.
const today = shallowRef<Temporal.PlainDate>();
onMounted(() => {
today.value = Temporal.Now.plainDateISO();
});
const days = shallowRef<Temporal.PlainDate[]>([]);
</script>
<template>
<Calendar.Root
v-model="days"
multiple
:max-days="3"
:min="today"
locale="en-US"
aria-label="Interview days"
class="relative box-border min-h-79 w-72 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"
>
<div class="absolute top-3 right-3 flex gap-1">
<Calendar.PreviousButton
class="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"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton
class="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"
>›</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 leading-5 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="box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:not-data-unavailable: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 data-unavailable:cursor-default data-unavailable:line-through disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:not-data-unavailable:bg-neutral-800 dark:focus-visible:outline-white dark:data-outside-month:not-data-selected:text-neutral-400 dark:data-selected:bg-white dark:data-selected: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"
>{{ days.length }} of 3 days selected.</Calendar.Footer
>
</Calendar.Root>
</template>Disabled days
This calendar is for a delivery on a working day in the 8 weeks from today. min and max disable the days outside them, and the navigation buttons stop at them. disabledDates matches Saturday and Sunday, so the keys skip them.
<script setup lang="ts">
import { computed, onMounted, shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import styles from '../../_index.module.css';
// A server does not know the day of the reader, so the value comes after the mount.
const today = shallowRef<Temporal.PlainDate>();
onMounted(() => {
today.value = Temporal.Now.plainDateISO();
});
const lastDay = computed(() => today.value?.add({ weeks: 8 }));
const selected = shallowRef<Temporal.PlainDate | null>(null);
</script>
<template>
<Calendar.Root
v-model="selected"
:min="today"
:max="lastDay"
:disabled-dates="{ dayOfWeek: [6, 7] }"
locale="en-US"
aria-label="Delivery day"
:class="[styles.Root, styles.SixWeeks]"
>
<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>
</Calendar.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
width: 18rem;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(14.5% 0 0deg);
background-color: white;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
color: white;
background-color: oklch(14.5% 0 0deg);
}
}
/* The month comes after the mount, so the root keeps the room of a caption and six weeks. */
.SixWeeks {
min-height: 19.75rem;
}
.WithWeekNumbers {
width: 20.25rem;
}
.WithMonths {
width: fit-content;
max-width: 100%;
}
.Nav {
position: absolute;
top: 0.75rem;
right: 0.75rem;
display: flex;
gap: 0.25rem;
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Selects {
display: flex;
gap: 0.25rem;
margin-bottom: 0.5rem;
}
.Select {
box-sizing: border-box;
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 1px solid oklch(55.6% 0 0deg);
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
@media (prefers-color-scheme: dark) {
border-color: oklch(70.8% 0 0deg);
color-scheme: dark;
}
&: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;
}
}
}
.Button,
.Title {
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
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']) {
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;
}
}
}
.Button {
width: 2rem;
}
.Title {
padding: 0 0.75rem;
font-weight: 600;
}
.Months {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
}
.Month {
width: 16rem;
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday,
.WeekNumber {
font-size: 0.75rem;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Weekday {
padding: 0.25rem 0;
font-weight: 500;
}
.WeekNumber {
padding: 0;
font-weight: 400;
font-variant-numeric: tabular-nums;
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.Cell {
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;
@media (hover: hover) {
&:hover:not([data-selected], [aria-selected='true'], :disabled, [data-unavailable]) {
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);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
&[data-unavailable] {
text-decoration: line-through;
cursor: default;
}
&[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;
}
.Holiday[data-holiday] {
position: relative;
&::after {
content: '';
position: absolute;
bottom: 0.25rem;
left: 50%;
width: 0.25rem;
height: 0.25rem;
border-radius: 50%;
background-color: currentColor;
translate: -50% 0;
}
}
.Rows {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.Row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.25rem;
}
.Cell {
height: 2.5rem;
}
.Footer {
margin-top: 0.5rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Pages {
--page-direction: 1;
position: relative;
&[data-navigation-direction='previous'] {
--page-direction: -1;
}
}
.Page {
position: relative;
}
/* The demo gives `<Transition>` the name `calendar-page`. */
.PageGrid:global(.calendar-page-enter-active),
.PageGrid:global(.calendar-page-leave-active) {
transition:
opacity 200ms ease-out,
translate 200ms ease-out;
@media (prefers-reduced-motion: reduce) {
transition: none;
}
}
.PageGrid:global(.calendar-page-enter-from) {
opacity: 0;
translate: calc(0.5rem * var(--page-direction)) 0;
}
/* The grid that leaves stays where it is, above the grid that enters. */
.PageGrid:global(.calendar-page-leave-active) {
position: absolute;
right: 0;
left: 0;
}
.PageGrid:global(.calendar-page-leave-to) {
opacity: 0;
translate: calc(-0.5rem * var(--page-direction)) 0;
}<script setup lang="ts">
import { computed, onMounted, shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
// A server does not know the day of the reader, so the value comes after the mount.
const today = shallowRef<Temporal.PlainDate>();
onMounted(() => {
today.value = Temporal.Now.plainDateISO();
});
const lastDay = computed(() => today.value?.add({ weeks: 8 }));
const selected = shallowRef<Temporal.PlainDate | null>(null);
</script>
<template>
<Calendar.Root
v-model="selected"
:min="today"
:max="lastDay"
:disabled-dates="{ dayOfWeek: [6, 7] }"
locale="en-US"
aria-label="Delivery day"
class="relative box-border min-h-79 w-72 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"
>
<div class="absolute top-3 right-3 flex gap-1">
<Calendar.PreviousButton
class="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"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton
class="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"
>›</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 leading-5 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="box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:not-data-unavailable: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 data-unavailable:cursor-default data-unavailable:line-through disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:not-data-unavailable:bg-neutral-800 dark:focus-visible:outline-white dark:data-outside-month:not-data-selected:text-neutral-400 dark:data-selected:bg-white dark:data-selected:text-neutral-950"
/>
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</Calendar.Root>
</template>disabledDates, unavailableDates, hiddenDates and modifiers take a matcher: a day, { start, end }, { before }, { after }, { dayOfWeek }, a function, or a list of these.
Unavailable days
Some days of this calendar are full. A day that unavailableDates matches stays in the sequence of the keys, and its button has aria-disabled. A screen reader user thus finds the day and hears that it is not available. The style sheet draws a line through the number of such a day.
<script setup lang="ts">
import { computed, onMounted, shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import styles from '../../_index.module.css';
// A server does not know the day of the reader, so the value comes after the mount.
const today = shallowRef<Temporal.PlainDate>();
onMounted(() => {
today.value = Temporal.Now.plainDateISO();
});
const booked = computed(() =>
today.value
? [
today.value.add({ days: 4 }),
{ start: today.value.add({ days: 10 }), end: today.value.add({ days: 13 }) },
]
: [],
);
const selected = shallowRef<Temporal.PlainDate | null>(null);
</script>
<template>
<Calendar.Root
v-model="selected"
:min="today"
:unavailable-dates="booked"
locale="en-US"
aria-label="Appointment day"
:class="[styles.Root, styles.SixWeeks]"
>
<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>
</Calendar.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
width: 18rem;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(14.5% 0 0deg);
background-color: white;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
color: white;
background-color: oklch(14.5% 0 0deg);
}
}
/* The month comes after the mount, so the root keeps the room of a caption and six weeks. */
.SixWeeks {
min-height: 19.75rem;
}
.WithWeekNumbers {
width: 20.25rem;
}
.WithMonths {
width: fit-content;
max-width: 100%;
}
.Nav {
position: absolute;
top: 0.75rem;
right: 0.75rem;
display: flex;
gap: 0.25rem;
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Selects {
display: flex;
gap: 0.25rem;
margin-bottom: 0.5rem;
}
.Select {
box-sizing: border-box;
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 1px solid oklch(55.6% 0 0deg);
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
@media (prefers-color-scheme: dark) {
border-color: oklch(70.8% 0 0deg);
color-scheme: dark;
}
&: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;
}
}
}
.Button,
.Title {
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
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']) {
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;
}
}
}
.Button {
width: 2rem;
}
.Title {
padding: 0 0.75rem;
font-weight: 600;
}
.Months {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
}
.Month {
width: 16rem;
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday,
.WeekNumber {
font-size: 0.75rem;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Weekday {
padding: 0.25rem 0;
font-weight: 500;
}
.WeekNumber {
padding: 0;
font-weight: 400;
font-variant-numeric: tabular-nums;
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.Cell {
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;
@media (hover: hover) {
&:hover:not([data-selected], [aria-selected='true'], :disabled, [data-unavailable]) {
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);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
&[data-unavailable] {
text-decoration: line-through;
cursor: default;
}
&[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;
}
.Holiday[data-holiday] {
position: relative;
&::after {
content: '';
position: absolute;
bottom: 0.25rem;
left: 50%;
width: 0.25rem;
height: 0.25rem;
border-radius: 50%;
background-color: currentColor;
translate: -50% 0;
}
}
.Rows {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.Row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.25rem;
}
.Cell {
height: 2.5rem;
}
.Footer {
margin-top: 0.5rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Pages {
--page-direction: 1;
position: relative;
&[data-navigation-direction='previous'] {
--page-direction: -1;
}
}
.Page {
position: relative;
}
/* The demo gives `<Transition>` the name `calendar-page`. */
.PageGrid:global(.calendar-page-enter-active),
.PageGrid:global(.calendar-page-leave-active) {
transition:
opacity 200ms ease-out,
translate 200ms ease-out;
@media (prefers-reduced-motion: reduce) {
transition: none;
}
}
.PageGrid:global(.calendar-page-enter-from) {
opacity: 0;
translate: calc(0.5rem * var(--page-direction)) 0;
}
/* The grid that leaves stays where it is, above the grid that enters. */
.PageGrid:global(.calendar-page-leave-active) {
position: absolute;
right: 0;
left: 0;
}
.PageGrid:global(.calendar-page-leave-to) {
opacity: 0;
translate: calc(-0.5rem * var(--page-direction)) 0;
}<script setup lang="ts">
import { computed, onMounted, shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
// A server does not know the day of the reader, so the value comes after the mount.
const today = shallowRef<Temporal.PlainDate>();
onMounted(() => {
today.value = Temporal.Now.plainDateISO();
});
const booked = computed(() =>
today.value
? [
today.value.add({ days: 4 }),
{ start: today.value.add({ days: 10 }), end: today.value.add({ days: 13 }) },
]
: [],
);
const selected = shallowRef<Temporal.PlainDate | null>(null);
</script>
<template>
<Calendar.Root
v-model="selected"
:min="today"
:unavailable-dates="booked"
locale="en-US"
aria-label="Appointment day"
class="relative box-border min-h-79 w-72 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"
>
<div class="absolute top-3 right-3 flex gap-1">
<Calendar.PreviousButton
class="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"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton
class="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"
>›</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 leading-5 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="box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:not-data-unavailable: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 data-unavailable:cursor-default data-unavailable:line-through disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:not-data-unavailable:bg-neutral-800 dark:focus-visible:outline-white dark:data-outside-month:not-data-selected:text-neutral-400 dark:data-selected:bg-white dark:data-selected:text-neutral-950"
/>
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</Calendar.Root>
</template>Modifiers
modifiers gives a name to the days that a matcher matches, and each such day has data-<name>. This calendar marks the public holidays with the modifier holiday, and the style sheet draws a dot on a day that has data-holiday. A screen reader does not read the dot, so the button of such a day has the name of the holiday as its aria-description.
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
<script setup lang="ts">
import { computed, shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import styles from '../../_index.module.css';
const holidays = [
{ date: Temporal.PlainDate.from('2026-11-11'), name: 'Veterans Day' },
{ date: Temporal.PlainDate.from('2026-11-26'), name: 'Thanksgiving Day' },
{ date: Temporal.PlainDate.from('2026-12-25'), name: 'Christmas Day' },
];
const modifiers = { holiday: holidays.map(({ date }) => date) };
const selected = shallowRef<Temporal.PlainDate | null>(Temporal.PlainDate.from('2026-11-26'));
function holidayName(date: Temporal.PlainDate | null) {
return holidays.find((holiday) => date?.equals(holiday.date))?.name;
}
const message = computed(() => holidayName(selected.value) ?? 'A dot marks a public holiday.');
</script>
<template>
<Calendar.Root
v-model="selected"
:modifiers="modifiers"
locale="en-US"
aria-label="Day off"
:class="[styles.Root, styles.SixWeeks]"
>
<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
:aria-description="holidayName(day)"
:class="[styles.DayButton, styles.Holiday]"
/>
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
<Calendar.Footer :class="styles.Footer">{{ message }}</Calendar.Footer>
</Calendar.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
width: 18rem;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(14.5% 0 0deg);
background-color: white;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
color: white;
background-color: oklch(14.5% 0 0deg);
}
}
/* The month comes after the mount, so the root keeps the room of a caption and six weeks. */
.SixWeeks {
min-height: 19.75rem;
}
.WithWeekNumbers {
width: 20.25rem;
}
.WithMonths {
width: fit-content;
max-width: 100%;
}
.Nav {
position: absolute;
top: 0.75rem;
right: 0.75rem;
display: flex;
gap: 0.25rem;
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Selects {
display: flex;
gap: 0.25rem;
margin-bottom: 0.5rem;
}
.Select {
box-sizing: border-box;
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 1px solid oklch(55.6% 0 0deg);
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
@media (prefers-color-scheme: dark) {
border-color: oklch(70.8% 0 0deg);
color-scheme: dark;
}
&: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;
}
}
}
.Button,
.Title {
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
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']) {
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;
}
}
}
.Button {
width: 2rem;
}
.Title {
padding: 0 0.75rem;
font-weight: 600;
}
.Months {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
}
.Month {
width: 16rem;
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday,
.WeekNumber {
font-size: 0.75rem;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Weekday {
padding: 0.25rem 0;
font-weight: 500;
}
.WeekNumber {
padding: 0;
font-weight: 400;
font-variant-numeric: tabular-nums;
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.Cell {
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;
@media (hover: hover) {
&:hover:not([data-selected], [aria-selected='true'], :disabled, [data-unavailable]) {
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);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
&[data-unavailable] {
text-decoration: line-through;
cursor: default;
}
&[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;
}
.Holiday[data-holiday] {
position: relative;
&::after {
content: '';
position: absolute;
bottom: 0.25rem;
left: 50%;
width: 0.25rem;
height: 0.25rem;
border-radius: 50%;
background-color: currentColor;
translate: -50% 0;
}
}
.Rows {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.Row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.25rem;
}
.Cell {
height: 2.5rem;
}
.Footer {
margin-top: 0.5rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Pages {
--page-direction: 1;
position: relative;
&[data-navigation-direction='previous'] {
--page-direction: -1;
}
}
.Page {
position: relative;
}
/* The demo gives `<Transition>` the name `calendar-page`. */
.PageGrid:global(.calendar-page-enter-active),
.PageGrid:global(.calendar-page-leave-active) {
transition:
opacity 200ms ease-out,
translate 200ms ease-out;
@media (prefers-reduced-motion: reduce) {
transition: none;
}
}
.PageGrid:global(.calendar-page-enter-from) {
opacity: 0;
translate: calc(0.5rem * var(--page-direction)) 0;
}
/* The grid that leaves stays where it is, above the grid that enters. */
.PageGrid:global(.calendar-page-leave-active) {
position: absolute;
right: 0;
left: 0;
}
.PageGrid:global(.calendar-page-leave-to) {
opacity: 0;
translate: calc(-0.5rem * var(--page-direction)) 0;
}<script setup lang="ts">
import { computed, shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
const holidays = [
{ date: Temporal.PlainDate.from('2026-11-11'), name: 'Veterans Day' },
{ date: Temporal.PlainDate.from('2026-11-26'), name: 'Thanksgiving Day' },
{ date: Temporal.PlainDate.from('2026-12-25'), name: 'Christmas Day' },
];
const modifiers = { holiday: holidays.map(({ date }) => date) };
const selected = shallowRef<Temporal.PlainDate | null>(Temporal.PlainDate.from('2026-11-26'));
function holidayName(date: Temporal.PlainDate | null) {
return holidays.find((holiday) => date?.equals(holiday.date))?.name;
}
const message = computed(() => holidayName(selected.value) ?? 'A dot marks a public holiday.');
</script>
<template>
<Calendar.Root
v-model="selected"
:modifiers="modifiers"
locale="en-US"
aria-label="Day off"
class="relative box-border min-h-79 w-72 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"
>
<div class="absolute top-3 right-3 flex gap-1">
<Calendar.PreviousButton
class="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"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton
class="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"
>›</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 leading-5 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
:aria-description="holidayName(day)"
class="box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:not-data-unavailable: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 data-unavailable:cursor-default data-unavailable:line-through disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:not-data-unavailable:bg-neutral-800 dark:focus-visible:outline-white dark:data-outside-month:not-data-selected:text-neutral-400 dark:data-selected:bg-white dark:data-selected:text-neutral-950 data-holiday:relative data-holiday:after:absolute data-holiday:after:bottom-1 data-holiday:after:left-1/2 data-holiday:after:size-1 data-holiday:after:-translate-x-1/2 data-holiday:after:rounded-full data-holiday:after:bg-current data-holiday:after:content-['']"
/>
</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">{{
message
}}</Calendar.Footer>
</Calendar.Root>
</template>More than one month
numberOfMonths shows that number of months, one after the other, and state.multipleMonths of the root is true. With pagedNavigation, the navigation buttons move by that number of months. Without it, they move by one month.
<script setup lang="ts">
import { onMounted, shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import styles from '../../_index.module.css';
// A server does not know the day of the reader, so the value comes after the mount.
const today = shallowRef<Temporal.PlainDate>();
onMounted(() => {
today.value = Temporal.Now.plainDateISO();
});
const selected = shallowRef<Temporal.PlainDate | null>(null);
</script>
<template>
<Calendar.Root
v-model="selected"
:number-of-months="2"
paged-navigation
:min="today"
locale="en-US"
aria-label="Departure day"
:class="[styles.Root, styles.SixWeeks, styles.WithMonths]"
>
<div :class="styles.Nav">
<Calendar.PreviousButton :class="styles.Button">‹</Calendar.PreviousButton>
<Calendar.NextButton :class="styles.Button">›</Calendar.NextButton>
</div>
<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.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
width: 18rem;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(14.5% 0 0deg);
background-color: white;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
color: white;
background-color: oklch(14.5% 0 0deg);
}
}
/* The month comes after the mount, so the root keeps the room of a caption and six weeks. */
.SixWeeks {
min-height: 19.75rem;
}
.WithWeekNumbers {
width: 20.25rem;
}
.WithMonths {
width: fit-content;
max-width: 100%;
}
.Nav {
position: absolute;
top: 0.75rem;
right: 0.75rem;
display: flex;
gap: 0.25rem;
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Selects {
display: flex;
gap: 0.25rem;
margin-bottom: 0.5rem;
}
.Select {
box-sizing: border-box;
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 1px solid oklch(55.6% 0 0deg);
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
@media (prefers-color-scheme: dark) {
border-color: oklch(70.8% 0 0deg);
color-scheme: dark;
}
&: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;
}
}
}
.Button,
.Title {
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
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']) {
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;
}
}
}
.Button {
width: 2rem;
}
.Title {
padding: 0 0.75rem;
font-weight: 600;
}
.Months {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
}
.Month {
width: 16rem;
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday,
.WeekNumber {
font-size: 0.75rem;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Weekday {
padding: 0.25rem 0;
font-weight: 500;
}
.WeekNumber {
padding: 0;
font-weight: 400;
font-variant-numeric: tabular-nums;
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.Cell {
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;
@media (hover: hover) {
&:hover:not([data-selected], [aria-selected='true'], :disabled, [data-unavailable]) {
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);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
&[data-unavailable] {
text-decoration: line-through;
cursor: default;
}
&[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;
}
.Holiday[data-holiday] {
position: relative;
&::after {
content: '';
position: absolute;
bottom: 0.25rem;
left: 50%;
width: 0.25rem;
height: 0.25rem;
border-radius: 50%;
background-color: currentColor;
translate: -50% 0;
}
}
.Rows {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.Row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.25rem;
}
.Cell {
height: 2.5rem;
}
.Footer {
margin-top: 0.5rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Pages {
--page-direction: 1;
position: relative;
&[data-navigation-direction='previous'] {
--page-direction: -1;
}
}
.Page {
position: relative;
}
/* The demo gives `<Transition>` the name `calendar-page`. */
.PageGrid:global(.calendar-page-enter-active),
.PageGrid:global(.calendar-page-leave-active) {
transition:
opacity 200ms ease-out,
translate 200ms ease-out;
@media (prefers-reduced-motion: reduce) {
transition: none;
}
}
.PageGrid:global(.calendar-page-enter-from) {
opacity: 0;
translate: calc(0.5rem * var(--page-direction)) 0;
}
/* The grid that leaves stays where it is, above the grid that enters. */
.PageGrid:global(.calendar-page-leave-active) {
position: absolute;
right: 0;
left: 0;
}
.PageGrid:global(.calendar-page-leave-to) {
opacity: 0;
translate: calc(-0.5rem * var(--page-direction)) 0;
}<script setup lang="ts">
import { onMounted, shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
// A server does not know the day of the reader, so the value comes after the mount.
const today = shallowRef<Temporal.PlainDate>();
onMounted(() => {
today.value = Temporal.Now.plainDateISO();
});
const selected = shallowRef<Temporal.PlainDate | null>(null);
</script>
<template>
<Calendar.Root
v-model="selected"
:number-of-months="2"
paged-navigation
:min="today"
locale="en-US"
aria-label="Departure day"
class="relative box-border min-h-79 w-fit max-w-full 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"
>
<div class="absolute top-3 right-3 flex gap-1">
<Calendar.PreviousButton
class="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"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton
class="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"
>›</Calendar.NextButton
>
</div>
<Calendar.Months class="flex flex-wrap gap-6">
<template #month="{ month }">
<Calendar.Month :month="month" class="w-64">
<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 leading-5 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="box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:not-data-unavailable: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 data-unavailable:cursor-default data-unavailable:line-through disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:not-data-unavailable:bg-neutral-800 dark:focus-visible:outline-white dark:data-outside-month:not-data-selected:text-neutral-400 dark:data-selected:bg-white dark:data-selected:text-neutral-950"
/>
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</Calendar.Root>
</template>Month and year selects
This calendar is for a date of birth. Calendar.MonthSelect and Calendar.YearSelect choose the month and the year of the page, and each is a native <select>. The years go from the year of min to the year of max, and order="desc" puts the last year first.
<script setup lang="ts">
import { onMounted, shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import styles from '../../_index.module.css';
// A server does not know the day of the reader, so the value comes after the mount.
const today = shallowRef<Temporal.PlainDate>();
onMounted(() => {
today.value = Temporal.Now.plainDateISO();
});
const firstDay = Temporal.PlainDate.from('1926-01-01');
const selected = shallowRef<Temporal.PlainDate | null>(null);
</script>
<template>
<Calendar.Root
v-model="selected"
:min="firstDay"
:max="today"
locale="en-US"
aria-label="Date of birth"
:class="[styles.Root, styles.SixWeeks]"
>
<div :class="styles.Selects">
<Calendar.MonthSelect format="short" :class="styles.Select" />
<Calendar.YearSelect order="desc" :class="styles.Select" />
</div>
<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.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.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
width: 18rem;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(14.5% 0 0deg);
background-color: white;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
color: white;
background-color: oklch(14.5% 0 0deg);
}
}
/* The month comes after the mount, so the root keeps the room of a caption and six weeks. */
.SixWeeks {
min-height: 19.75rem;
}
.WithWeekNumbers {
width: 20.25rem;
}
.WithMonths {
width: fit-content;
max-width: 100%;
}
.Nav {
position: absolute;
top: 0.75rem;
right: 0.75rem;
display: flex;
gap: 0.25rem;
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Selects {
display: flex;
gap: 0.25rem;
margin-bottom: 0.5rem;
}
.Select {
box-sizing: border-box;
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 1px solid oklch(55.6% 0 0deg);
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
@media (prefers-color-scheme: dark) {
border-color: oklch(70.8% 0 0deg);
color-scheme: dark;
}
&: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;
}
}
}
.Button,
.Title {
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
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']) {
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;
}
}
}
.Button {
width: 2rem;
}
.Title {
padding: 0 0.75rem;
font-weight: 600;
}
.Months {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
}
.Month {
width: 16rem;
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday,
.WeekNumber {
font-size: 0.75rem;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Weekday {
padding: 0.25rem 0;
font-weight: 500;
}
.WeekNumber {
padding: 0;
font-weight: 400;
font-variant-numeric: tabular-nums;
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.Cell {
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;
@media (hover: hover) {
&:hover:not([data-selected], [aria-selected='true'], :disabled, [data-unavailable]) {
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);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
&[data-unavailable] {
text-decoration: line-through;
cursor: default;
}
&[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;
}
.Holiday[data-holiday] {
position: relative;
&::after {
content: '';
position: absolute;
bottom: 0.25rem;
left: 50%;
width: 0.25rem;
height: 0.25rem;
border-radius: 50%;
background-color: currentColor;
translate: -50% 0;
}
}
.Rows {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.Row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.25rem;
}
.Cell {
height: 2.5rem;
}
.Footer {
margin-top: 0.5rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Pages {
--page-direction: 1;
position: relative;
&[data-navigation-direction='previous'] {
--page-direction: -1;
}
}
.Page {
position: relative;
}
/* The demo gives `<Transition>` the name `calendar-page`. */
.PageGrid:global(.calendar-page-enter-active),
.PageGrid:global(.calendar-page-leave-active) {
transition:
opacity 200ms ease-out,
translate 200ms ease-out;
@media (prefers-reduced-motion: reduce) {
transition: none;
}
}
.PageGrid:global(.calendar-page-enter-from) {
opacity: 0;
translate: calc(0.5rem * var(--page-direction)) 0;
}
/* The grid that leaves stays where it is, above the grid that enters. */
.PageGrid:global(.calendar-page-leave-active) {
position: absolute;
right: 0;
left: 0;
}
.PageGrid:global(.calendar-page-leave-to) {
opacity: 0;
translate: calc(-0.5rem * var(--page-direction)) 0;
}<script setup lang="ts">
import { onMounted, shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
// A server does not know the day of the reader, so the value comes after the mount.
const today = shallowRef<Temporal.PlainDate>();
onMounted(() => {
today.value = Temporal.Now.plainDateISO();
});
const firstDay = Temporal.PlainDate.from('1926-01-01');
const selected = shallowRef<Temporal.PlainDate | null>(null);
</script>
<template>
<Calendar.Root
v-model="selected"
:min="firstDay"
:max="today"
locale="en-US"
aria-label="Date of birth"
class="relative box-border min-h-79 w-72 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"
>
<div class="mb-2 flex gap-1">
<Calendar.MonthSelect
format="short"
class="box-border h-8 cursor-pointer rounded-md border border-neutral-500 px-2 outline-0 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950 disabled:cursor-default disabled:opacity-40 dark:border-neutral-400 dark:scheme-dark dark:focus-visible:outline-white"
/>
<Calendar.YearSelect
order="desc"
class="box-border h-8 cursor-pointer rounded-md border border-neutral-500 px-2 outline-0 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950 disabled:cursor-default disabled:opacity-40 dark:border-neutral-400 dark:scheme-dark dark:focus-visible:outline-white"
/>
</div>
<div class="absolute top-3 right-3 flex gap-1">
<Calendar.PreviousButton
class="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"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton
class="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"
>›</Calendar.NextButton
>
</div>
<Calendar.Months>
<template #month="{ month }">
<Calendar.Month :month="month">
<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 leading-5 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="box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:not-data-unavailable: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 data-unavailable:cursor-default data-unavailable:line-through disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:not-data-unavailable:bg-neutral-800 dark:focus-visible:outline-white dark:data-outside-month:not-data-selected:text-neutral-400 dark:data-selected:bg-white dark:data-selected:text-neutral-950"
/>
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</Calendar.Root>
</template>Week numbers
Calendar.WeekNumber shows the number of a week, and Calendar.WeekNumberHeader is the header of that column. The numbers follow the first day of the week and firstWeekContainsDate.
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import styles from '../../_index.module.css';
const selected = shallowRef<Temporal.PlainDate | null>(null);
</script>
<template>
<Calendar.Root
v-model="selected"
locale="en-US"
aria-label="Start of the sprint"
:class="[styles.Root, styles.SixWeeks, styles.WithWeekNumbers]"
>
<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>
<Calendar.WeekNumberHeader :class="styles.Weekday">#</Calendar.WeekNumberHeader>
<template #weekday="{ weekday }">
<Calendar.Weekday :weekday="weekday" :class="styles.Weekday" />
</template>
</Calendar.GridHeaderRow>
</Calendar.GridHeader>
<Calendar.GridBody>
<template #week="{ week }">
<Calendar.Week :week="week">
<Calendar.WeekNumber :week="week" :class="styles.WeekNumber" />
<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.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
width: 18rem;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(14.5% 0 0deg);
background-color: white;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
color: white;
background-color: oklch(14.5% 0 0deg);
}
}
/* The month comes after the mount, so the root keeps the room of a caption and six weeks. */
.SixWeeks {
min-height: 19.75rem;
}
.WithWeekNumbers {
width: 20.25rem;
}
.WithMonths {
width: fit-content;
max-width: 100%;
}
.Nav {
position: absolute;
top: 0.75rem;
right: 0.75rem;
display: flex;
gap: 0.25rem;
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Selects {
display: flex;
gap: 0.25rem;
margin-bottom: 0.5rem;
}
.Select {
box-sizing: border-box;
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 1px solid oklch(55.6% 0 0deg);
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
@media (prefers-color-scheme: dark) {
border-color: oklch(70.8% 0 0deg);
color-scheme: dark;
}
&: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;
}
}
}
.Button,
.Title {
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
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']) {
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;
}
}
}
.Button {
width: 2rem;
}
.Title {
padding: 0 0.75rem;
font-weight: 600;
}
.Months {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
}
.Month {
width: 16rem;
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday,
.WeekNumber {
font-size: 0.75rem;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Weekday {
padding: 0.25rem 0;
font-weight: 500;
}
.WeekNumber {
padding: 0;
font-weight: 400;
font-variant-numeric: tabular-nums;
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.Cell {
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;
@media (hover: hover) {
&:hover:not([data-selected], [aria-selected='true'], :disabled, [data-unavailable]) {
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);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
&[data-unavailable] {
text-decoration: line-through;
cursor: default;
}
&[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;
}
.Holiday[data-holiday] {
position: relative;
&::after {
content: '';
position: absolute;
bottom: 0.25rem;
left: 50%;
width: 0.25rem;
height: 0.25rem;
border-radius: 50%;
background-color: currentColor;
translate: -50% 0;
}
}
.Rows {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.Row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.25rem;
}
.Cell {
height: 2.5rem;
}
.Footer {
margin-top: 0.5rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Pages {
--page-direction: 1;
position: relative;
&[data-navigation-direction='previous'] {
--page-direction: -1;
}
}
.Page {
position: relative;
}
/* The demo gives `<Transition>` the name `calendar-page`. */
.PageGrid:global(.calendar-page-enter-active),
.PageGrid:global(.calendar-page-leave-active) {
transition:
opacity 200ms ease-out,
translate 200ms ease-out;
@media (prefers-reduced-motion: reduce) {
transition: none;
}
}
.PageGrid:global(.calendar-page-enter-from) {
opacity: 0;
translate: calc(0.5rem * var(--page-direction)) 0;
}
/* The grid that leaves stays where it is, above the grid that enters. */
.PageGrid:global(.calendar-page-leave-active) {
position: absolute;
right: 0;
left: 0;
}
.PageGrid:global(.calendar-page-leave-to) {
opacity: 0;
translate: calc(-0.5rem * var(--page-direction)) 0;
}<script setup lang="ts">
import { shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
const selected = shallowRef<Temporal.PlainDate | null>(null);
</script>
<template>
<Calendar.Root
v-model="selected"
locale="en-US"
aria-label="Start of the sprint"
class="relative box-border min-h-79 w-81 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"
>
<div class="absolute top-3 right-3 flex gap-1">
<Calendar.PreviousButton
class="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"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton
class="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"
>›</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>
<Calendar.WeekNumberHeader
class="py-1 text-center text-xs leading-5 font-medium text-neutral-600 dark:text-neutral-400"
>#</Calendar.WeekNumberHeader
>
<template #weekday="{ weekday }">
<Calendar.Weekday
:weekday="weekday"
class="py-1 text-center text-xs leading-5 font-medium text-neutral-600 dark:text-neutral-400"
/>
</template>
</Calendar.GridHeaderRow>
</Calendar.GridHeader>
<Calendar.GridBody>
<template #week="{ week }">
<Calendar.Week :week="week">
<Calendar.WeekNumber
:week="week"
class="p-0 text-center text-xs leading-5 font-normal tabular-nums text-neutral-600 dark:text-neutral-400"
/>
<template #day="{ day }">
<Calendar.Day :day="day" class="p-0 text-center">
<Calendar.DayButton
class="box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:not-data-unavailable: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 data-unavailable:cursor-default data-unavailable:line-through disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:not-data-unavailable:bg-neutral-800 dark:focus-visible:outline-white dark:data-outside-month:not-data-selected:text-neutral-400 dark:data-selected:bg-white dark:data-selected:text-neutral-950"
/>
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</Calendar.Root>
</template>Broadcast calendar
broadcastCalendar shows the broadcast months. A broadcast month has four or five whole weeks that start on Monday, so the grid also shows days of the months around it. The first week of a broadcast year holds January 1, so this calendar sets firstWeekContainsDate to 1. Without it, the weeks have their ISO 8601 numbers.
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import styles from '../../_index.module.css';
const selected = shallowRef<Temporal.PlainDate | null>(null);
</script>
<template>
<Calendar.Root
v-model="selected"
broadcast-calendar
:first-week-contains-date="1"
locale="en-US"
aria-label="Air date"
:class="[styles.Root, styles.SixWeeks, styles.WithWeekNumbers]"
>
<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>
<Calendar.WeekNumberHeader :class="styles.Weekday">#</Calendar.WeekNumberHeader>
<template #weekday="{ weekday }">
<Calendar.Weekday :weekday="weekday" :class="styles.Weekday" />
</template>
</Calendar.GridHeaderRow>
</Calendar.GridHeader>
<Calendar.GridBody>
<template #week="{ week }">
<Calendar.Week :week="week">
<Calendar.WeekNumber :week="week" :class="styles.WeekNumber" />
<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.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
width: 18rem;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(14.5% 0 0deg);
background-color: white;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
color: white;
background-color: oklch(14.5% 0 0deg);
}
}
/* The month comes after the mount, so the root keeps the room of a caption and six weeks. */
.SixWeeks {
min-height: 19.75rem;
}
.WithWeekNumbers {
width: 20.25rem;
}
.WithMonths {
width: fit-content;
max-width: 100%;
}
.Nav {
position: absolute;
top: 0.75rem;
right: 0.75rem;
display: flex;
gap: 0.25rem;
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Selects {
display: flex;
gap: 0.25rem;
margin-bottom: 0.5rem;
}
.Select {
box-sizing: border-box;
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 1px solid oklch(55.6% 0 0deg);
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
@media (prefers-color-scheme: dark) {
border-color: oklch(70.8% 0 0deg);
color-scheme: dark;
}
&: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;
}
}
}
.Button,
.Title {
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
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']) {
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;
}
}
}
.Button {
width: 2rem;
}
.Title {
padding: 0 0.75rem;
font-weight: 600;
}
.Months {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
}
.Month {
width: 16rem;
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday,
.WeekNumber {
font-size: 0.75rem;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Weekday {
padding: 0.25rem 0;
font-weight: 500;
}
.WeekNumber {
padding: 0;
font-weight: 400;
font-variant-numeric: tabular-nums;
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.Cell {
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;
@media (hover: hover) {
&:hover:not([data-selected], [aria-selected='true'], :disabled, [data-unavailable]) {
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);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
&[data-unavailable] {
text-decoration: line-through;
cursor: default;
}
&[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;
}
.Holiday[data-holiday] {
position: relative;
&::after {
content: '';
position: absolute;
bottom: 0.25rem;
left: 50%;
width: 0.25rem;
height: 0.25rem;
border-radius: 50%;
background-color: currentColor;
translate: -50% 0;
}
}
.Rows {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.Row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.25rem;
}
.Cell {
height: 2.5rem;
}
.Footer {
margin-top: 0.5rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Pages {
--page-direction: 1;
position: relative;
&[data-navigation-direction='previous'] {
--page-direction: -1;
}
}
.Page {
position: relative;
}
/* The demo gives `<Transition>` the name `calendar-page`. */
.PageGrid:global(.calendar-page-enter-active),
.PageGrid:global(.calendar-page-leave-active) {
transition:
opacity 200ms ease-out,
translate 200ms ease-out;
@media (prefers-reduced-motion: reduce) {
transition: none;
}
}
.PageGrid:global(.calendar-page-enter-from) {
opacity: 0;
translate: calc(0.5rem * var(--page-direction)) 0;
}
/* The grid that leaves stays where it is, above the grid that enters. */
.PageGrid:global(.calendar-page-leave-active) {
position: absolute;
right: 0;
left: 0;
}
.PageGrid:global(.calendar-page-leave-to) {
opacity: 0;
translate: calc(-0.5rem * var(--page-direction)) 0;
}<script setup lang="ts">
import { shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
const selected = shallowRef<Temporal.PlainDate | null>(null);
</script>
<template>
<Calendar.Root
v-model="selected"
broadcast-calendar
:first-week-contains-date="1"
locale="en-US"
aria-label="Air date"
class="relative box-border min-h-79 w-81 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"
>
<div class="absolute top-3 right-3 flex gap-1">
<Calendar.PreviousButton
class="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"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton
class="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"
>›</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>
<Calendar.WeekNumberHeader
class="py-1 text-center text-xs leading-5 font-medium text-neutral-600 dark:text-neutral-400"
>#</Calendar.WeekNumberHeader
>
<template #weekday="{ weekday }">
<Calendar.Weekday
:weekday="weekday"
class="py-1 text-center text-xs leading-5 font-medium text-neutral-600 dark:text-neutral-400"
/>
</template>
</Calendar.GridHeaderRow>
</Calendar.GridHeader>
<Calendar.GridBody>
<template #week="{ week }">
<Calendar.Week :week="week">
<Calendar.WeekNumber
:week="week"
class="p-0 text-center text-xs leading-5 font-normal tabular-nums text-neutral-600 dark:text-neutral-400"
/>
<template #day="{ day }">
<Calendar.Day :day="day" class="p-0 text-center">
<Calendar.DayButton
class="box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:not-data-unavailable: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 data-unavailable:cursor-default data-unavailable:line-through disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:not-data-unavailable:bg-neutral-800 dark:focus-visible:outline-white dark:data-outside-month:not-data-selected:text-neutral-400 dark:data-selected:bg-white dark:data-selected:text-neutral-950"
/>
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</Calendar.Root>
</template>A page of weeks or days
visibleDuration shows one page of weeks or days in place of a month, and the navigation buttons move by that page. This calendar shows one week. format of Calendar.Caption gives the form of the first day and the last day of the page.
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import styles from '../../_index.module.css';
const captionFormat: Intl.DateTimeFormatOptions = { month: 'short', day: 'numeric' };
const selected = shallowRef<Temporal.PlainDate | null>(null);
</script>
<template>
<Calendar.Root
v-model="selected"
:visible-duration="{ weeks: 1 }"
locale="en-US"
aria-label="Day of the agenda"
:class="styles.Root"
>
<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 :format="captionFormat" :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.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
width: 18rem;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(14.5% 0 0deg);
background-color: white;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
color: white;
background-color: oklch(14.5% 0 0deg);
}
}
/* The month comes after the mount, so the root keeps the room of a caption and six weeks. */
.SixWeeks {
min-height: 19.75rem;
}
.WithWeekNumbers {
width: 20.25rem;
}
.WithMonths {
width: fit-content;
max-width: 100%;
}
.Nav {
position: absolute;
top: 0.75rem;
right: 0.75rem;
display: flex;
gap: 0.25rem;
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Selects {
display: flex;
gap: 0.25rem;
margin-bottom: 0.5rem;
}
.Select {
box-sizing: border-box;
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 1px solid oklch(55.6% 0 0deg);
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
@media (prefers-color-scheme: dark) {
border-color: oklch(70.8% 0 0deg);
color-scheme: dark;
}
&: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;
}
}
}
.Button,
.Title {
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
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']) {
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;
}
}
}
.Button {
width: 2rem;
}
.Title {
padding: 0 0.75rem;
font-weight: 600;
}
.Months {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
}
.Month {
width: 16rem;
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday,
.WeekNumber {
font-size: 0.75rem;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Weekday {
padding: 0.25rem 0;
font-weight: 500;
}
.WeekNumber {
padding: 0;
font-weight: 400;
font-variant-numeric: tabular-nums;
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.Cell {
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;
@media (hover: hover) {
&:hover:not([data-selected], [aria-selected='true'], :disabled, [data-unavailable]) {
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);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
&[data-unavailable] {
text-decoration: line-through;
cursor: default;
}
&[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;
}
.Holiday[data-holiday] {
position: relative;
&::after {
content: '';
position: absolute;
bottom: 0.25rem;
left: 50%;
width: 0.25rem;
height: 0.25rem;
border-radius: 50%;
background-color: currentColor;
translate: -50% 0;
}
}
.Rows {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.Row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.25rem;
}
.Cell {
height: 2.5rem;
}
.Footer {
margin-top: 0.5rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Pages {
--page-direction: 1;
position: relative;
&[data-navigation-direction='previous'] {
--page-direction: -1;
}
}
.Page {
position: relative;
}
/* The demo gives `<Transition>` the name `calendar-page`. */
.PageGrid:global(.calendar-page-enter-active),
.PageGrid:global(.calendar-page-leave-active) {
transition:
opacity 200ms ease-out,
translate 200ms ease-out;
@media (prefers-reduced-motion: reduce) {
transition: none;
}
}
.PageGrid:global(.calendar-page-enter-from) {
opacity: 0;
translate: calc(0.5rem * var(--page-direction)) 0;
}
/* The grid that leaves stays where it is, above the grid that enters. */
.PageGrid:global(.calendar-page-leave-active) {
position: absolute;
right: 0;
left: 0;
}
.PageGrid:global(.calendar-page-leave-to) {
opacity: 0;
translate: calc(-0.5rem * var(--page-direction)) 0;
}<script setup lang="ts">
import { shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
const captionFormat: Intl.DateTimeFormatOptions = { month: 'short', day: 'numeric' };
const selected = shallowRef<Temporal.PlainDate | null>(null);
</script>
<template>
<Calendar.Root
v-model="selected"
:visible-duration="{ weeks: 1 }"
locale="en-US"
aria-label="Day of the agenda"
class="relative box-border w-72 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"
>
<div class="absolute top-3 right-3 flex gap-1">
<Calendar.PreviousButton
class="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"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton
class="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"
>›</Calendar.NextButton
>
</div>
<Calendar.Months>
<template #month="{ month }">
<Calendar.Month :month="month">
<Calendar.Caption
:format="captionFormat"
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 leading-5 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="box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:not-data-unavailable: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 data-unavailable:cursor-default data-unavailable:line-through disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:not-data-unavailable:bg-neutral-800 dark:focus-visible:outline-white dark:data-outside-month:not-data-selected:text-neutral-400 dark:data-selected:bg-white dark:data-selected:text-neutral-950"
/>
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Calendar.Month>
</template>
</Calendar.Months>
</Calendar.Root>
</template>Time zone
The value of this calendar is a call at 09:00 in Tokyo, a Temporal.ZonedDateTime. A press moves the call to another day. With no today, the calendar reads the clock in the zone of a zoned value after the mount, so the today of this calendar is the day in Tokyo. For another zone, give today, such as Temporal.Now.plainDateISO('Europe/Paris').
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
<script setup lang="ts">
import { computed, shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import styles from '../../_index.module.css';
const call = shallowRef(Temporal.ZonedDateTime.from('2026-11-17T09:00[Asia/Tokyo]'));
const summary = computed(() => {
const date = call.value.toPlainDate().toString();
const time = call.value.toPlainTime().toString({ smallestUnit: 'minute' });
return `${date} at ${time}, ${call.value.timeZoneId}`;
});
</script>
<template>
<Calendar.Root
v-model="call"
locale="en-US"
aria-label="Day of the call"
:class="[styles.Root, styles.SixWeeks]"
>
<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>
<Calendar.Footer :class="styles.Footer">{{ summary }}</Calendar.Footer>
</Calendar.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
width: 18rem;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(14.5% 0 0deg);
background-color: white;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
color: white;
background-color: oklch(14.5% 0 0deg);
}
}
/* The month comes after the mount, so the root keeps the room of a caption and six weeks. */
.SixWeeks {
min-height: 19.75rem;
}
.WithWeekNumbers {
width: 20.25rem;
}
.WithMonths {
width: fit-content;
max-width: 100%;
}
.Nav {
position: absolute;
top: 0.75rem;
right: 0.75rem;
display: flex;
gap: 0.25rem;
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Selects {
display: flex;
gap: 0.25rem;
margin-bottom: 0.5rem;
}
.Select {
box-sizing: border-box;
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 1px solid oklch(55.6% 0 0deg);
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
@media (prefers-color-scheme: dark) {
border-color: oklch(70.8% 0 0deg);
color-scheme: dark;
}
&: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;
}
}
}
.Button,
.Title {
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
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']) {
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;
}
}
}
.Button {
width: 2rem;
}
.Title {
padding: 0 0.75rem;
font-weight: 600;
}
.Months {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
}
.Month {
width: 16rem;
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday,
.WeekNumber {
font-size: 0.75rem;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Weekday {
padding: 0.25rem 0;
font-weight: 500;
}
.WeekNumber {
padding: 0;
font-weight: 400;
font-variant-numeric: tabular-nums;
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.Cell {
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;
@media (hover: hover) {
&:hover:not([data-selected], [aria-selected='true'], :disabled, [data-unavailable]) {
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);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
&[data-unavailable] {
text-decoration: line-through;
cursor: default;
}
&[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;
}
.Holiday[data-holiday] {
position: relative;
&::after {
content: '';
position: absolute;
bottom: 0.25rem;
left: 50%;
width: 0.25rem;
height: 0.25rem;
border-radius: 50%;
background-color: currentColor;
translate: -50% 0;
}
}
.Rows {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.Row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.25rem;
}
.Cell {
height: 2.5rem;
}
.Footer {
margin-top: 0.5rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Pages {
--page-direction: 1;
position: relative;
&[data-navigation-direction='previous'] {
--page-direction: -1;
}
}
.Page {
position: relative;
}
/* The demo gives `<Transition>` the name `calendar-page`. */
.PageGrid:global(.calendar-page-enter-active),
.PageGrid:global(.calendar-page-leave-active) {
transition:
opacity 200ms ease-out,
translate 200ms ease-out;
@media (prefers-reduced-motion: reduce) {
transition: none;
}
}
.PageGrid:global(.calendar-page-enter-from) {
opacity: 0;
translate: calc(0.5rem * var(--page-direction)) 0;
}
/* The grid that leaves stays where it is, above the grid that enters. */
.PageGrid:global(.calendar-page-leave-active) {
position: absolute;
right: 0;
left: 0;
}
.PageGrid:global(.calendar-page-leave-to) {
opacity: 0;
translate: calc(-0.5rem * var(--page-direction)) 0;
}<script setup lang="ts">
import { computed, shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
const call = shallowRef(Temporal.ZonedDateTime.from('2026-11-17T09:00[Asia/Tokyo]'));
const summary = computed(() => {
const date = call.value.toPlainDate().toString();
const time = call.value.toPlainTime().toString({ smallestUnit: 'minute' });
return `${date} at ${time}, ${call.value.timeZoneId}`;
});
</script>
<template>
<Calendar.Root
v-model="call"
locale="en-US"
aria-label="Day of the call"
class="relative box-border min-h-79 w-72 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"
>
<div class="absolute top-3 right-3 flex gap-1">
<Calendar.PreviousButton
class="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"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton
class="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"
>›</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 leading-5 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="box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:not-data-unavailable: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 data-unavailable:cursor-default data-unavailable:line-through disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:not-data-unavailable:bg-neutral-800 dark:focus-visible:outline-white dark:data-outside-month:not-data-selected:text-neutral-400 dark:data-selected:bg-white dark:data-selected: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>
</Calendar.Root>
</template>Another calendar
calendar shows the dates in another calendar, such as persian, and the value keeps its own calendar. This calendar shows Persian months, and its value is an ISO date. With no calendar, the grid shows the calendar of a value that is not ISO, else the Gregorian calendar.
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
import styles from '../../_index.module.css';
const selected = shallowRef(Temporal.PlainDate.from('2026-11-14'));
</script>
<template>
<Calendar.Root
v-model="selected"
calendar="persian"
locale="en-US"
:class="[styles.Root, styles.SixWeeks]"
>
<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>
<Calendar.Footer :class="styles.Footer">Value: {{ selected.toString() }}</Calendar.Footer>
</Calendar.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
width: 18rem;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(14.5% 0 0deg);
background-color: white;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
color: white;
background-color: oklch(14.5% 0 0deg);
}
}
/* The month comes after the mount, so the root keeps the room of a caption and six weeks. */
.SixWeeks {
min-height: 19.75rem;
}
.WithWeekNumbers {
width: 20.25rem;
}
.WithMonths {
width: fit-content;
max-width: 100%;
}
.Nav {
position: absolute;
top: 0.75rem;
right: 0.75rem;
display: flex;
gap: 0.25rem;
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Selects {
display: flex;
gap: 0.25rem;
margin-bottom: 0.5rem;
}
.Select {
box-sizing: border-box;
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 1px solid oklch(55.6% 0 0deg);
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
@media (prefers-color-scheme: dark) {
border-color: oklch(70.8% 0 0deg);
color-scheme: dark;
}
&: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;
}
}
}
.Button,
.Title {
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
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']) {
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;
}
}
}
.Button {
width: 2rem;
}
.Title {
padding: 0 0.75rem;
font-weight: 600;
}
.Months {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
}
.Month {
width: 16rem;
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday,
.WeekNumber {
font-size: 0.75rem;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Weekday {
padding: 0.25rem 0;
font-weight: 500;
}
.WeekNumber {
padding: 0;
font-weight: 400;
font-variant-numeric: tabular-nums;
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.Cell {
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;
@media (hover: hover) {
&:hover:not([data-selected], [aria-selected='true'], :disabled, [data-unavailable]) {
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);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
&[data-unavailable] {
text-decoration: line-through;
cursor: default;
}
&[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;
}
.Holiday[data-holiday] {
position: relative;
&::after {
content: '';
position: absolute;
bottom: 0.25rem;
left: 50%;
width: 0.25rem;
height: 0.25rem;
border-radius: 50%;
background-color: currentColor;
translate: -50% 0;
}
}
.Rows {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.Row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.25rem;
}
.Cell {
height: 2.5rem;
}
.Footer {
margin-top: 0.5rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Pages {
--page-direction: 1;
position: relative;
&[data-navigation-direction='previous'] {
--page-direction: -1;
}
}
.Page {
position: relative;
}
/* The demo gives `<Transition>` the name `calendar-page`. */
.PageGrid:global(.calendar-page-enter-active),
.PageGrid:global(.calendar-page-leave-active) {
transition:
opacity 200ms ease-out,
translate 200ms ease-out;
@media (prefers-reduced-motion: reduce) {
transition: none;
}
}
.PageGrid:global(.calendar-page-enter-from) {
opacity: 0;
translate: calc(0.5rem * var(--page-direction)) 0;
}
/* The grid that leaves stays where it is, above the grid that enters. */
.PageGrid:global(.calendar-page-leave-active) {
position: absolute;
right: 0;
left: 0;
}
.PageGrid:global(.calendar-page-leave-to) {
opacity: 0;
translate: calc(-0.5rem * var(--page-direction)) 0;
}<script setup lang="ts">
import { shallowRef } from 'vue';
import { Calendar } from '@vase-ui/vue/calendar';
const selected = shallowRef(Temporal.PlainDate.from('2026-11-14'));
</script>
<template>
<Calendar.Root
v-model="selected"
calendar="persian"
locale="en-US"
class="relative box-border min-h-79 w-72 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"
>
<div class="absolute top-3 right-3 flex gap-1">
<Calendar.PreviousButton
class="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"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton
class="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"
>›</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 leading-5 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="box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:not-data-unavailable: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 data-unavailable:cursor-default data-unavailable:line-through disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:not-data-unavailable:bg-neutral-800 dark:focus-visible:outline-white dark:data-outside-month:not-data-selected:text-neutral-400 dark:data-selected:bg-white dark:data-selected: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"
>Value: {{ selected.toString() }}</Calendar.Footer
>
</Calendar.Root>
</template>Animate the page
Put Calendar.Grid in a <Transition>, with the first day of the month as its key. The grid that leaves is inert. data-navigation-direction of the root and of Calendar.Months gives the side of the move: previous, next or none. This calendar fades each grid and moves it 0.5rem, to the left for next and to the right for previous. The caption stays, and its live region reads the new month. fixedWeeks and showOutsideDays give each page six rows of buttons, so the grid keeps its height. The style sheet has no transition for a person who prefers reduced motion.
<script setup lang="ts">
import { Calendar } from '@vase-ui/vue/calendar';
import styles from '../../_index.module.css';
</script>
<template>
<Calendar.Root
fixed-weeks
show-outside-days
locale="en-US"
:class="[styles.Root, styles.SixWeeks]"
>
<div :class="styles.Nav">
<Calendar.PreviousButton :class="styles.Button">‹</Calendar.PreviousButton>
<Calendar.NextButton :class="styles.Button">›</Calendar.NextButton>
</div>
<Calendar.Months :class="styles.Pages">
<template #month="{ month }">
<Calendar.Month :month="month" :class="styles.Page">
<Calendar.Caption :class="styles.Caption" />
<Transition name="calendar-page">
<Calendar.Grid :key="month.first.toString()" :class="[styles.Grid, styles.PageGrid]">
<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>
</Transition>
</Calendar.Month>
</template>
</Calendar.Months>
</Calendar.Root>
</template>.Root {
position: relative;
box-sizing: border-box;
width: 18rem;
padding: 0.75rem;
border: 1px solid oklch(92.2% 0 0deg);
border-radius: 0.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
color: oklch(14.5% 0 0deg);
background-color: white;
@media (prefers-color-scheme: dark) {
border-color: oklch(26.9% 0 0deg);
color: white;
background-color: oklch(14.5% 0 0deg);
}
}
/* The month comes after the mount, so the root keeps the room of a caption and six weeks. */
.SixWeeks {
min-height: 19.75rem;
}
.WithWeekNumbers {
width: 20.25rem;
}
.WithMonths {
width: fit-content;
max-width: 100%;
}
.Nav {
position: absolute;
top: 0.75rem;
right: 0.75rem;
display: flex;
gap: 0.25rem;
}
.Header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.Caption {
display: flex;
align-items: center;
height: 2rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.Selects {
display: flex;
gap: 0.25rem;
margin-bottom: 0.5rem;
}
.Select {
box-sizing: border-box;
height: 2rem;
margin: 0;
padding: 0 0.5rem;
border: 1px solid oklch(55.6% 0 0deg);
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
cursor: pointer;
@media (prefers-color-scheme: dark) {
border-color: oklch(70.8% 0 0deg);
color-scheme: dark;
}
&: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;
}
}
}
.Button,
.Title {
height: 2rem;
margin: 0;
padding: 0;
border: 0;
border-radius: 0.375rem;
font: inherit;
color: inherit;
background-color: transparent;
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']) {
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;
}
}
}
.Button {
width: 2rem;
}
.Title {
padding: 0 0.75rem;
font-weight: 600;
}
.Months {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
}
.Month {
width: 16rem;
}
.Grid {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.Weekday,
.WeekNumber {
font-size: 0.75rem;
text-align: center;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Weekday {
padding: 0.25rem 0;
font-weight: 500;
}
.WeekNumber {
padding: 0;
font-weight: 400;
font-variant-numeric: tabular-nums;
}
.Day {
padding: 0;
text-align: center;
}
.DayButton,
.Cell {
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;
@media (hover: hover) {
&:hover:not([data-selected], [aria-selected='true'], :disabled, [data-unavailable]) {
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);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
&[data-unavailable] {
text-decoration: line-through;
cursor: default;
}
&[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;
}
.Holiday[data-holiday] {
position: relative;
&::after {
content: '';
position: absolute;
bottom: 0.25rem;
left: 50%;
width: 0.25rem;
height: 0.25rem;
border-radius: 50%;
background-color: currentColor;
translate: -50% 0;
}
}
.Rows {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.Row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.25rem;
}
.Cell {
height: 2.5rem;
}
.Footer {
margin-top: 0.5rem;
color: oklch(43.9% 0 0deg);
@media (prefers-color-scheme: dark) {
color: oklch(70.8% 0 0deg);
}
}
.Pages {
--page-direction: 1;
position: relative;
&[data-navigation-direction='previous'] {
--page-direction: -1;
}
}
.Page {
position: relative;
}
/* The demo gives `<Transition>` the name `calendar-page`. */
.PageGrid:global(.calendar-page-enter-active),
.PageGrid:global(.calendar-page-leave-active) {
transition:
opacity 200ms ease-out,
translate 200ms ease-out;
@media (prefers-reduced-motion: reduce) {
transition: none;
}
}
.PageGrid:global(.calendar-page-enter-from) {
opacity: 0;
translate: calc(0.5rem * var(--page-direction)) 0;
}
/* The grid that leaves stays where it is, above the grid that enters. */
.PageGrid:global(.calendar-page-leave-active) {
position: absolute;
right: 0;
left: 0;
}
.PageGrid:global(.calendar-page-leave-to) {
opacity: 0;
translate: calc(-0.5rem * var(--page-direction)) 0;
}<script setup lang="ts">
import { Calendar } from '@vase-ui/vue/calendar';
</script>
<template>
<Calendar.Root
fixed-weeks
show-outside-days
locale="en-US"
class="relative box-border min-h-79 w-72 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"
>
<div class="absolute top-3 right-3 flex gap-1">
<Calendar.PreviousButton
class="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"
>‹</Calendar.PreviousButton
>
<Calendar.NextButton
class="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"
>›</Calendar.NextButton
>
</div>
<Calendar.Months
class="relative [--page-direction:1] data-[navigation-direction=previous]:[--page-direction:-1]"
>
<template #month="{ month }">
<Calendar.Month :month="month" class="relative">
<Calendar.Caption class="mb-2 flex h-8 items-center font-semibold" />
<Transition name="calendar-page">
<Calendar.Grid
:key="month.first.toString()"
class="w-full table-fixed border-collapse [&.calendar-page-enter-active,&.calendar-page-leave-active]:transition-[opacity,translate] [&.calendar-page-enter-active,&.calendar-page-leave-active]:duration-200 [&.calendar-page-enter-active,&.calendar-page-leave-active]:ease-[ease-out] motion-reduce:[&.calendar-page-enter-active,&.calendar-page-leave-active]:transition-none [&.calendar-page-enter-from]:translate-x-[calc(0.5rem*var(--page-direction))] [&.calendar-page-enter-from]:opacity-0 [&.calendar-page-leave-active]:absolute [&.calendar-page-leave-active]:inset-x-0 [&.calendar-page-leave-to]:translate-x-[calc(-0.5rem*var(--page-direction))] [&.calendar-page-leave-to]:opacity-0"
>
<Calendar.GridHeader>
<Calendar.GridHeaderRow>
<template #weekday="{ weekday }">
<Calendar.Weekday
:weekday="weekday"
class="py-1 text-center text-xs leading-5 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="box-border size-9 cursor-pointer rounded-md border border-transparent outline-0 hover:enabled:not-data-selected:not-data-unavailable: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 data-unavailable:cursor-default data-unavailable:line-through disabled:cursor-default disabled:opacity-40 dark:hover:enabled:not-data-selected:not-data-unavailable:bg-neutral-800 dark:focus-visible:outline-white dark:data-outside-month:not-data-selected:text-neutral-400 dark:data-selected:bg-white dark:data-selected:text-neutral-950"
/>
</Calendar.Day>
</template>
</Calendar.Week>
</template>
</Calendar.GridBody>
</Calendar.Grid>
</Transition>
</Calendar.Month>
</template>
</Calendar.Months>
</Calendar.Root>
</template>Render on the server
No render reads the clock or the locale of the visitor. Give locale or a LocaleProvider, or the text is en-US. With no today, the root reads the clock after the mount, so the server HTML marks no day as today. With no value, month, defaultMonth or focused day, the server HTML also has no month, and the page of today comes after the mount. Give defaultMonth, or keep the room of the month in CSS. A server that knows the day of the visitor gives today. An expression of Temporal.Now in a template can give another day in the browser.
A server and a browser can write other names of the days and another form of a date. Calendar.Weekday, Calendar.Caption and Calendar.ViewTrigger have data-allow-mismatch="text", so the hydration writes the text of the browser with no message. Vue allows another text only in an element whose one child is that text. With as or a default slot, put the text in an element of the default slot. In another part, also give that element data-allow-mismatch="text". A name in an aria-* attribute keeps the text of the server until the part renders again.
Keyboard
| Key | Action |
|---|---|
| Tab | Moves the focus to the tab stop of the grid. The tab stop is the focused day, month or year. Else it is the first selected one, else today, else the first one that can take the focus. |
| Left Arrow, Right Arrow | Moves the focus to the day, the month or the year 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, or columns cells before or after in a grid of months or years. |
| Home, End | Moves the focus to the first or the last day of the week, or to the first or the last cell of the row. |
| Page Up, Page Down | Moves the focus to the same day of the month before or after. In the grid of months, it moves a year. In the grid of years, it moves visibleYears years. |
| Shift+Page Up, Shift+Page Down | Moves the focus to the same day a year before or after. It does nothing in a grid of months or years. |
| Shift+Left, Shift+Right | Moves the focus to the same day a month before or after. With multiple, it moves one day and adds that day to the selection. It does nothing in a grid of months or years. |
| Shift+Up, Shift+Down | Moves the focus to the same day a year before or after. With multiple, it moves one week and adds that day to the selection. It does nothing in a grid of months or years. |
| Enter, Space | Selects the day, or the month of a month picker. In the grid of years, shows the months of the year. In the grid of months of a calendar of days, shows the days of the month. |
API reference
Calendar.Root
Groups all parts of the calendar.
Renders a <div> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
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 | (Multiple extends true ? readonly Value[] : Value | null) | undefined | The value at the mount of an uncontrolled calendar. It also gives the kind of a new value. | |
defaultView | CalendarRootView | undefined | The view at the mount of an uncontrolled view. The default is day, and month for a value
that is a year and month. | |
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. | |
disabledMonths | ((month: Temporal.PlainYearMonth) => boolean) | undefined | The months that take no focus and no selection, in the calendar of the grid. | |
disabledYears | ((year: Temporal.PlainYearMonth) => boolean) | undefined | The years that take no focus, as the first month of each year, in the calendar of the grid. | |
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 values with multiple. A press adds a value only below it. | |
min | DateValue | undefined | The first day that the user can select. An earlier day is disabled. | |
minDays | number | undefined | 0 | The least number of values with multiple. A press removes a value only above it. |
modelValue | (Multiple extends true ? readonly Value[] : Value | null) | undefined | The selected value, or the list of selected values with multiple. v-model binds it. A
Temporal.PlainYearMonth selects a month in the grid of months. Its months show in calendar
only when the two calendars have the same months, as gregory and buddhist do. A new value
has the kind, the calendar, the time and the zone of the first value, else of defaultValue,
else of the last value. 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. | |
multiple | (Multiple & boolean) | undefined | false | The user selects a list of days or months. A press on a selected day removes it. Without it, a press on the selected day keeps it. |
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. | |
view | CalendarRootView | undefined | What the grid shows. v-model:view binds it. | |
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. | |
visibleYears | number | undefined | 12 | The number of years on a page of years. A page starts with a multiple of this number. |
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: CalendarRootState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarRootState | 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: Multiple extends true ? Value[] : Value, details: CalendarRootChangeEventDetails] | The user changes the value. details.cancel() keeps the value as it is. |
update:modelValue | [value: Multiple extends true ? Value[] : Value] | Comes after valueChange, unless a listener cancels the change. v-model uses it. |
monthChange | [month: Temporal.PlainYearMonth, details: CalendarRootChangeEventDetails] | 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: CalendarRootChangeEventDetails] | A day or a cell 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. |
viewChange | [view: CalendarRootView, details: CalendarRootChangeEventDetails] | The user shows another view. details.cancel() keeps the view. |
update:view | [view: CalendarRootView] | Comes after viewChange, unless a listener cancels the change. v-model:view 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 or the cell that has the tab stop. With date, shows its page and focuses it, when it can take the focus. |
Selectors
| Selector | Description |
|---|---|
[data-view] | What the grid shows: day, month or year. |
[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 and no month is selected. |
Calendar.PreviousButton
A button that shows the page before. A hold of the button repeats the move.
Renders a <button> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
disabled | boolean | undefined | false | The user cannot press the button. A disabled calendar also disables it. |
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: CalendarState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarState | 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 |
|---|---|
:disabled | The button or the calendar is disabled, and the button is a native button. |
[aria-disabled="true"] | The page is at min, or the button is another element and is disabled. |
[data-readonly] | The calendar is read-only. |
[data-invalid] | The value of the calendar is not valid. |
[data-empty] | No day and no month is selected. |
Calendar.NextButton
A button that shows the page after. A hold of the button repeats the move.
Renders a <button> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
disabled | boolean | undefined | false | The user cannot press the button. A disabled calendar also disables it. |
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: CalendarState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarState | 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 |
|---|---|
:disabled | The button or the calendar is disabled, and the button is a native button. |
[aria-disabled="true"] | The page is at max, or the button is another element and is disabled. |
[data-readonly] | The calendar is read-only. |
[data-invalid] | The value of the calendar is not valid. |
[data-empty] | No day and no month is selected. |
Calendar.ViewTrigger
A button that shows the grid of months or of years, and then the first view again.
Renders a <button> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
disabled | boolean | undefined | false | The user cannot press the trigger. A disabled calendar also disables it. |
view | "month" | "year" | undefined | 'year' | The view that a press shows. A second press shows the first view again: the days, or the months of a month picker. |
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: CalendarViewTriggerStatetext: string | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarViewTriggerStatetext: string | 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-active] | The grid shows the view of the trigger. |
:disabled | The trigger is a native button, and it is disabled: by its prop, by the calendar, or because the calendar shows days only. |
[aria-disabled="true"] | The trigger is another element, and it is disabled. |
[data-readonly] | The calendar is read-only. |
[data-invalid] | The value of the calendar is not valid. |
[data-empty] | No day and no month is selected. |
Calendar.Months
Renders the months of the page, one for each item of its slot month.
Renders a <div> element, only in the view of days.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
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 |
|---|---|---|
month | month: CalendarPageindex: number | One month of the page. The months render by their place, so a month part stays when the page moves. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarMonthsStatemonths: readonly CalendarPage[] | 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-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 and no month is selected. |
Calendar.Month
Groups the parts of one month of the page.
Renders a <div> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
month | CalendarPage | Required | The page that the part shows. It is the value of the slot month of Calendar.Months. |
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: CalendarMonthState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarMonthState | 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-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 and no month is selected. |
Calendar.Caption
The name of the month. It names the grid of the month.
Renders a <div> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
format | Intl.DateTimeFormatOptions | undefined | The format of the text. The default is the month and the year in full. | |
id | string | undefined | The grid of the month names itself by this id in aria-labelledby. | |
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: CalendarStatetext: string | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarStatetext: string | 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-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 and no month is selected. |
Calendar.MonthSelect
A select of the month of the page.
Renders a <select> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
format | NonNullable<"numeric" | "long" | "2-digit" | "short" | "narrow" | undefined> | undefined | 'long' | The length of the name of a month. |
Slots
| Slot | Slot props | Description |
|---|---|---|
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarStateoptions: readonly CalendarSelectOption[]value: string | 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 | HTMLSelectElement | null | The element of the part, or null while it is not mounted. |
Selectors
| Selector | Description |
|---|---|
:disabled | The calendar is disabled, or the calendar shows no month. |
[data-readonly] | The calendar is read-only. |
[data-invalid] | The value of the calendar is not valid. |
[data-empty] | No day and no month is selected. |
Calendar.YearSelect
A select of the year of the page.
Renders a <select> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
format | NonNullable<"numeric" | "2-digit" | undefined> | undefined | 'numeric' | The form of a year. |
order | "asc" | "desc" | undefined | 'asc' | The order of the years. |
Slots
| Slot | Slot props | Description |
|---|---|---|
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarStateoptions: readonly CalendarSelectOption[]value: string | 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 | HTMLSelectElement | null | The element of the part, or null while it is not mounted. |
Selectors
| Selector | Description |
|---|---|
:disabled | The calendar is disabled, or the calendar shows no month. |
[data-readonly] | The calendar is read-only. |
[data-invalid] | The value of the calendar is not valid. |
[data-empty] | No day and no month is selected. |
Calendar.Grid
The grid of the days of a month.
Renders a <table> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
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: CalendarState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarState | 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-disabled="true"] | The calendar is disabled. |
[aria-readonly="true"] | The calendar is read-only. |
[data-invalid] | The value of the calendar is not valid. |
[data-empty] | No day and no month is selected. |
Calendar.GridHeader
The head of the grid.
Renders a <thead> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
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: CalendarState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarState | 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-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 and no month is selected. |
Calendar.GridHeaderRow
The row of the names of the days.
Renders a <tr> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
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 | The content before the names of the days, such as Calendar.WeekNumberHeader. | |
weekday | weekday: DayOfWeekindex: number | One day of the week, from the first day of the week. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarStateweekdays: readonly DayOfWeek[] | 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-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 and no month is selected. |
Calendar.Weekday
The name of a day of the week.
Renders a <th> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
format | NonNullable<"long" | "short" | "narrow" | undefined> | undefined | 'short' | The length of the name. |
weekday | DayOfWeek | Required | The day of the week. It is the value of the slot weekday of Calendar.GridHeaderRow. |
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: CalendarStatetext: string | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarStatetext: string | 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-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 and no month is selected. |
Calendar.WeekNumberHeader
The head of the column of week numbers.
Renders a <th> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
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: CalendarState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarState | 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-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 and no month is selected. |
Calendar.GridBody
The weeks of the grid.
Renders a <tbody> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
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 |
|---|---|---|
week | week: CalendarWeekindex: number | One week of the month. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarStateweeks: readonly CalendarWeek[] | 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-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 and no month is selected. |
Calendar.Week
A row of days.
Renders a <tr> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
week | CalendarWeek | Required | The week that the part shows. It is the value of the slot week of Calendar.GridBody. |
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 | The content before the days, such as Calendar.WeekNumber. | |
day | day: Temporal.PlainDateindex: number | One day of the week. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarStatedays: readonly Temporal.PlainDate[] | 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-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 and no month is selected. |
Calendar.WeekNumber
The number of a week.
Renders a <th> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
week | CalendarWeek | Required | The week of the row. |
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: CalendarWeekNumberStatetext: string | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarWeekNumberStatetext: string | 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-week-number] | The number of the week, such as [data-week-number="1"]. |
[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 and no month is selected. |
Calendar.Day
A cell of the grid for one day.
Renders a <td> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
day | Temporal.PlainDate | Required | The day that the part shows. It is the value of the slot day of Calendar.Week. |
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: CalendarDayState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarDayState | 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-selected="true"] | The day is selected. |
[data-disabled] | The day takes no focus and no selection: the calendar is disabled, or min, max or disabledDates disables the day. |
[data-unavailable] | unavailableDates matches the day. |
[data-hidden] | The day has no button. |
[data-today] | The day is today. |
[data-outside-month] | The day is in the month before or after the month of its page. |
[data-range-start] | The day is the first day of the range of RangeCalendar.Root. |
[data-range-end] | The day is the last day of the range of RangeCalendar.Root. |
[data-range-middle] | The day is between the two ends of the range of RangeCalendar.Root. |
[data-<modifier>] | A rule of modifiers matches the day, such as [data-holiday] for the rule holiday. |
Calendar.DayButton
The button of a day, which selects it.
Renders a <button> element, and no element for a hidden day.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
format | Intl.DateTimeFormatOptions | undefined | The format of the name of the button. The default is the weekday, the day, the month and the year. | |
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: CalendarDayStatetext: string | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarDayStatetext: string | 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-selected] | The day is selected. |
[aria-current="date"] | The day is today. |
:disabled | The button is a native button, and the day is disabled. |
[aria-disabled="true"] | The day is unavailable, or the button is another element and the day is disabled. |
[data-unavailable] | unavailableDates matches the day. |
[data-outside-month] | The day is in the month before or after the month of its page. |
[data-range-start] | The day is the first day of the range of RangeCalendar.Root. |
[data-range-end] | The day is the last day of the range of RangeCalendar.Root. |
[data-range-middle] | The day is between the two ends of the range of RangeCalendar.Root. |
[data-<modifier>] | A rule of modifiers matches the day, such as [data-holiday] for the rule holiday. |
Calendar.MonthGrid
The grid of the months of a year.
Renders a <div> element, only in the view of months.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
columns | number | undefined | 3 | The cells of a row. |
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 |
|---|---|---|
row | months: Temporal.PlainYearMonth[]index: number | One row of cells. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarStaterows: readonly Temporal.PlainYearMonth[][] | 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-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 and no month is selected. |
Calendar.MonthGridRow
A row of month cells.
Renders a <div> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
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: CalendarState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarState | 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-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 and no month is selected. |
Calendar.MonthCell
A month of the grid of months.
Renders a <button> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
format | NonNullable<"numeric" | "long" | "2-digit" | "short" | "narrow" | undefined> | undefined | 'long' | The length of the name of the month. |
month | Temporal.PlainYearMonth | Required | The month of the cell. It is an item of the slot row of Calendar.MonthGrid. |
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: CalendarCellStatetext: string | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarCellStatetext: string | 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-selected="true"] | A selected value is in the month. |
[aria-current="date"] | Today is in the month. |
:disabled | The cell is a native button, and the calendar, min, max or disabledMonths disables the month. |
[aria-disabled="true"] | The cell is another element, and the month is disabled. |
Calendar.YearGrid
The grid of a page of years.
Renders a <div> element, only in the view of years.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
columns | number | undefined | 3 | The cells of a row. |
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 |
|---|---|---|
row | years: Temporal.PlainYearMonth[]index: number | One row of cells. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarStaterows: readonly Temporal.PlainYearMonth[][] | 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-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 and no month is selected. |
Calendar.YearGridRow
A row of year cells.
Renders a <div> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
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: CalendarState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarState | 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-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 and no month is selected. |
Calendar.YearCell
A year of the grid of years.
Renders a <button> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
format | NonNullable<"numeric" | "2-digit" | undefined> | undefined | 'numeric' | The form of the year. |
year | Temporal.PlainYearMonth | Required | The first month of the year of the cell. It is an item of the slot row of Calendar.YearGrid. |
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: CalendarCellStatetext: string | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarCellStatetext: string | 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-selected="true"] | A selected value is in the year. |
[aria-current="date"] | Today is in the year. |
:disabled | The cell is a native button, and the calendar, min, max or disabledYears disables the year. |
[aria-disabled="true"] | The cell is another element, and the year is disabled. |
Calendar.Footer
A live region for text about the calendar.
Renders a <div> element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
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: CalendarState | The content of the part. |
element | props: Record<string, unknown>elementRef: (target: unknown) => voidstate: CalendarState | 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-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 and no month is selected. |
Calendar.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' | 'month-press' | 'year-press' | 'trigger-press' | 'month-change' | 'keyboard' | 'none'
Calendar.Root.View
What the grid shows: the days, the months of a year, or a page of years.
'day' | 'month' | 'year'
Differences from Base UI
Base UI has no Calendar. A person selects a day or a month in a grid, with the keys of the date picker dialog pattern. The value is a Temporal object.
- https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/examples/datepicker-dialog/
- https://www.w3.org/WAI/ARIA/apg/patterns/grid/
Behavior
| Vase UI | Evidence |
|---|---|
| A repeat button stops after one step when that step releases the press. Base UI starts its repeat timer after the first step returns, even if a pointer release ended the press during that step. |
The handbook gives the differences that all components share: Styling, Animation, Composition, Customization, Forms and TypeScript.