Range Calendar
A calendar component that allows users to select a range of dates.
Preview
Installation
npx sigma-ui@latest add range-calendarUsage
<script setup lang="ts">
import { type Ref, ref } from 'vue';
import type { DateRange } from 'reka-ui';
import { getLocalTimeZone, today } from '@internationalized/date';
import { RangeCalendar } from '@/components/ui/range-calendar';
const start = today(getLocalTimeZone());
const value = ref({
start,
end: start.add({ days: 7 }),
}) as Ref<DateRange>;
</script>
<template>
<RangeCalendar
v-model="value"
class="rounded-md border"
/>
</template>About
The <RangeCalendar /> component is built on top of the Reka UI Range Calendar component, which uses the @internationalized/date package to handle dates.
v-modelis aDateRangewithstartandenddate values.minValue,maxValue, andisDateUnavailablerestrict the dates that can be selected.
Examples
Two Months
Set number-of-months to display several months side by side.
<template>
<RangeCalendar
v-model="value"
:number-of-months="2"
class="rounded-md border"
/>
</template>API Reference
RangeCalendar
Props
| Prop | Type | Default |
|---|---|---|
defaultPlaceholderThe default placeholder date | DateValue | - |
defaultValueThe default value for the calendar | DateRange | - |
modelValueThe controlled selected date range of the calendar. Can be bound as | DateRange | null | - |
placeholderThe placeholder date, which is used to determine what month to display when no date is selected. This updates as the user navigates the calendar and can be used to programmatically control the calendar view | DateValue | - |
allowNonContiguousRangesWhen combined with | boolean | - |
pagedNavigationThis property causes the previous and next buttons to navigate by the number of months displayed at once, rather than one month | boolean | - |
preventDeselectWhether or not to prevent the user from deselecting a date without selecting another date first | boolean | - |
maximumDaysThe maximum number of days that can be selected in a range | number | - |
weekStartsOnThe day of the week to start the calendar on | WeekStartsOn | - |
weekdayFormatThe format to use for the weekday strings provided via the weekdays slot prop | WeekDayFormat | - |
calendarLabelThe accessible label for the calendar | string | - |
fixedWeeksWhether or not to always display 6 weeks in the calendar | boolean | - |
maxValueThe maximum date that can be selected | DateValue | - |
minValueThe minimum date that can be selected | DateValue | - |
localeThe locale to use for formatting dates | string | - |
numberOfMonthsThe number of months to display at once | number | - |
disabledWhether or not the calendar is disabled | boolean | - |
readonlyWhether or not the calendar is readonly | boolean | - |
initialFocusIf true, the calendar will focus the selected day, today, or the first day of the month depending on what is visible when the calendar is mounted | boolean | - |
isDateDisabledA function that returns whether or not a date is disabled | Matcher | - |
isDateUnavailableA function that returns whether or not a date is unavailable | Matcher | - |
isDateHighlightableA function that returns whether or not a date is hightable | Matcher | - |
dirThe reading direction of the calendar when applicable. <br> If omitted, inherits globally from | Direction | - |
nextPageA function that returns the next page of the calendar. It receives the current placeholder as an argument inside the component. | ((placeholder: DateValue) => DateValue) | - |
prevPageA function that returns the previous page of the calendar. It receives the current placeholder as an argument inside the component. | ((placeholder: DateValue) => DateValue) | - |
disableDaysOutsideCurrentViewWhether or not to disable days outside the current view. | boolean | - |
fixedDateWhich part of the range should be fixed | "start" | "end" | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Events
| Event | Payload |
|---|---|
update:modelValueEvent handler called whenever the model value changes | [date: DateRange] |
update:placeholderEvent handler called whenever the placeholder value changes | [date: DateValue] |
update:validModelValueEvent handler called whenever there is a new validModel | [date: DateRange] |
update:startValueEvent handler called whenever the start value changes | [date: DateValue] |
RangeCalendarCell
Props
| Prop | Type | Default |
|---|---|---|
daterequired | DateValue | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
RangeCalendarCellTrigger
Props
| Prop | Type | Default |
|---|---|---|
dayrequired | DateValue | - |
monthrequired | DateValue | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
RangeCalendarGrid
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
RangeCalendarGridBody
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
RangeCalendarGridHead
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
RangeCalendarGridRow
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
RangeCalendarHeadCell
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
RangeCalendarHeader
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
RangeCalendarHeading
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | { headingValue: string; } |
RangeCalendarNextButton
Props
| Prop | Type | Default |
|---|---|---|
nextPageThe function to be used for the next page. Overwrites the | ((placeholder: DateValue) => DateValue) | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
RangeCalendarPrevButton
Props
| Prop | Type | Default |
|---|---|---|
prevPageThe function to be used for the prev page. Overwrites the | ((placeholder: DateValue) => DateValue) | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
Accessibility
Renders the days as a grid of buttons with accessible date labels. Reka UI handles focus management and keyboard navigation.
| Key | Description |
|---|---|
| Tab | Moves focus to the navigation buttons, then to the focused day of the grid. |
| Space | When focus is on a navigation button, changes the month. When focus is on a day, selects it as the start or the end of the range. |
| Enter | When focus is on a navigation button, changes the month. When focus is on a day, selects it as the start or the end of the range. |
| ArrowRight | Moves focus to the next day. |
| ArrowLeft | Moves focus to the previous day. |
| ArrowDown | Moves focus to the same day of the next week. |
| ArrowUp | Moves focus to the same day of the previous week. |
| Esc | While a range is being selected, cancels the selection and restores the previous range. |