On this page

Range calendar

Install, props and the parts Range calendar is built from.

Install

Run this in the app, after shadcn-vue init and the Beehexa theme (Button › Code):

npx shadcn-vue@latest add https://beehexa.design/r/range-calendar.json

Use

The value is a DateRange ({ start, end }) of @internationalized/date values.

<script setup lang="ts">
import type { DateRange } from 'reka-ui'
import type { Ref } from 'vue'
import { getLocalTimeZone, today } from '@internationalized/date'
import { ref } from 'vue'
import { RangeCalendar } from '@/components/ui/range-calendar'

const end = today(getLocalTimeZone())
const value = ref({ start: end.subtract({ days: 6 }), end }) as Ref<DateRange>
</script>

<template>
  <RangeCalendar v-model="value" :number-of-months="2" :max-value="end" />
</template>

Props

Part Prop Values Notes
RangeCalendar v-model DateRange { start, end }; either can be undefined while picking
RangeCalendar min-value, max-value DateValue Days outside are disabled
RangeCalendar is-date-unavailable (date) => boolean Greyed and struck through; a range can’t include them
RangeCalendar number-of-months number Months side by side
RangeCalendar locale string Weekday and month names, first day of the week
RangeCalendar initial-focus boolean Focuses the start day, or today, when shown. Use it in a popover
RangeCalendar @update:start-value DateValue | undefined The start, as soon as it is picked

The parts (RangeCalendarCell, RangeCalendarCellTrigger, RangeCalendarGrid, RangeCalendarHeader, RangeCalendarHeading, RangeCalendarHeadCell, RangeCalendarPrevButton, RangeCalendarNextButton and the grid rows) are exported for a custom layout.

Built on

Wraps the reka-ui RangeCalendar with the shadcn-vue RangeCalendar API. reka-ui gives the grid roles, keyboard movement, locale handling and the range rules. Beehexa adds the styles and the bar under the days between.

Limitations

  • While the end is not picked yet, hovering a day does not preview the range.