Usage
The Calendar component allows users to select dates. It supports single date selection, multiple dates, and date ranges.
<template>
<UCalendar v-model="date" />
</template>
<script setup>
import { ref } from 'vue'
import { getLocalTimeZone, today } from '@internationalized/date'
const date = ref(today(getLocalTimeZone()))
</script>
Date Range Selection
Enable range selection by setting the range prop:
<template>
<UCalendar v-model="dateRange" range />
</template>
<script setup>
import { ref } from 'vue'
import { getLocalTimeZone, today } from '@internationalized/date'
const dateRange = ref({
start: today(getLocalTimeZone()),
end: today(getLocalTimeZone()).add({ days: 7 })
})
</script>
Multiple Date Selection
Allow selecting multiple individual dates:
<template>
<UCalendar v-model="dates" multiple />
</template>
<script setup>
import { ref } from 'vue'
import { getLocalTimeZone, today } from '@internationalized/date'
const dates = ref([
today(getLocalTimeZone()),
today(getLocalTimeZone()).add({ days: 3 })
])
</script>
Sizes
<template>
<div class="space-y-8">
<UCalendar v-model="date" size="sm" />
<UCalendar v-model="date" size="md" />
<UCalendar v-model="date" size="lg" />
</div>
</template>
<script setup>
import { ref } from 'vue'
import { getLocalTimeZone, today } from '@internationalized/date'
const date = ref(today(getLocalTimeZone()))
</script>
Colors
<template>
<div class="space-y-8">
<UCalendar v-model="date" color="primary" />
<UCalendar v-model="date" color="success" />
<UCalendar v-model="date" color="warning" />
</div>
</template>
<script setup>
import { ref } from 'vue'
import { getLocalTimeZone, today } from '@internationalized/date'
const date = ref(today(getLocalTimeZone()))
</script>
Variants
<template>
<div class="space-y-8">
<UCalendar v-model="date" variant="solid" />
<UCalendar v-model="date" variant="outline" />
</div>
</template>
<script setup>
import { ref } from 'vue'
import { getLocalTimeZone, today } from '@internationalized/date'
const date = ref(today(getLocalTimeZone()))
</script>
Disabled Dates
<template>
<UCalendar
v-model="date"
:is-date-disabled="isDateDisabled"
/>
</template>
<script setup>
import { ref } from 'vue'
import { getLocalTimeZone, today } from '@internationalized/date'
const date = ref(today(getLocalTimeZone()))
const isDateDisabled = (date) => {
// Disable weekends
const dayOfWeek = date.toDate(getLocalTimeZone()).getDay()
return dayOfWeek === 0 || dayOfWeek === 6
}
</script>
Min and Max Dates
<template>
<UCalendar
v-model="date"
:min-value="minDate"
:max-value="maxDate"
/>
</template>
<script setup>
import { ref } from 'vue'
import { getLocalTimeZone, today } from '@internationalized/date'
const date = ref(today(getLocalTimeZone()))
const minDate = today(getLocalTimeZone())
const maxDate = today(getLocalTimeZone()).add({ months: 3 })
</script>
Week Numbers
Display week numbers in the calendar:
<template>
<UCalendar v-model="date" week-numbers />
</template>
<script setup>
import { ref } from 'vue'
import { getLocalTimeZone, today } from '@internationalized/date'
const date = ref(today(getLocalTimeZone()))
</script>
Control Visibility
Customize which navigation controls are shown:
<template>
<UCalendar
v-model="date"
:month-controls="true"
:year-controls="false"
/>
</template>
<script setup>
import { ref } from 'vue'
import { getLocalTimeZone, today } from '@internationalized/date'
const date = ref(today(getLocalTimeZone()))
</script>
Custom Icons
<template>
<UCalendar
v-model="date"
next-month-icon="i-heroicons-arrow-right"
prev-month-icon="i-heroicons-arrow-left"
next-year-icon="i-heroicons-chevron-double-right"
prev-year-icon="i-heroicons-chevron-double-left"
/>
</template>
<script setup>
import { ref } from 'vue'
import { getLocalTimeZone, today } from '@internationalized/date'
const date = ref(today(getLocalTimeZone()))
</script>
Slots
Customize the calendar display with slots:
<template>
<UCalendar v-model="date">
<template #heading="{ value }">
<span class="font-bold text-xl">{{ value }}</span>
</template>
<template #day="{ day }">
<span>{{ day.day }}</span>
</template>
<template #week-day="{ day }">
<span class="text-xs uppercase">{{ day }}</span>
</template>
</UCalendar>
</template>
<script setup>
import { ref } from 'vue'
import { getLocalTimeZone, today } from '@internationalized/date'
const date = ref(today(getLocalTimeZone()))
</script>
Props
modelValue
DateValue | DateRange | DateValue[]
The controlled value of the calendar. Can be bound with v-model.
defaultValue
DateValue | DateRange | DateValue[]
The value of the calendar when initially rendered.
Whether or not a range of dates can be selected.
Whether or not multiple dates can be selected.
The color theme of the calendar.
The visual variant of the calendar.
The size of the calendar. Options: sm, md, lg.
Show month navigation controls.
Show year navigation controls.
Display week numbers in the calendar.
The icon to use for the next year control. Defaults to appConfig.ui.icons.chevronDoubleRight.
Configure the next year button properties.
The icon to use for the next month control. Defaults to appConfig.ui.icons.chevronRight.
Configure the next month button properties.
The icon to use for the previous year control. Defaults to appConfig.ui.icons.chevronDoubleLeft.
Configure the prev year button properties.
The icon to use for the previous month control. Defaults to appConfig.ui.icons.chevronLeft.
Configure the prev month button properties.
The minimum date that can be selected.
The maximum date that can be selected.
isDateDisabled
(date: DateValue) => boolean
Function to determine if a date should be disabled.
isDateUnavailable
(date: DateValue) => boolean
Function to determine if a date should be marked as unavailable.
Whether the calendar is disabled.
Whether the calendar is readonly.
Whether to always display 6 weeks in the calendar.
The number of months to display.
Whether to navigate by page (numberOfMonths) or by single month.
The format for weekday labels. Options: narrow, short, long.
The element or component this component should render as.
Additional CSS classes to apply to the root element.
UI customization object for styling different parts of the calendar.
Events
@update:modelValue
(date: DateValue | DateRange | DateValue[]) => void
Emitted when the selected date(s) change.
@update:startValue
(date: DateValue) => void
Emitted when the start date changes (range mode only).
Slots
Customize the calendar heading (month/year display).
Customize the day cell content.
Customize the weekday header content.