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/calendar.json
It also installs Button and Native select, which Calendar uses.
Use
Dates are @internationalized/date values, as in reka-ui.
<script setup lang="ts">
import type { DateValue } from '@internationalized/date'
import type { Ref } from 'vue'
import { getLocalTimeZone, today } from '@internationalized/date'
import { ref } from 'vue'
import { Calendar } from '@/components/ui/calendar'
const value = ref(today(getLocalTimeZone())) as Ref<DateValue>
</script>
<template>
<Calendar v-model="value" :min-value="today(getLocalTimeZone())" />
</template>
Props
| Part | Prop | Values | Notes |
|---|---|---|---|
Calendar |
v-model |
DateValue |
The picked day |
Calendar |
min-value, max-value |
DateValue |
Days outside are disabled |
Calendar |
is-date-unavailable |
(date) => boolean |
Greyed and struck through |
Calendar |
is-date-disabled |
(date) => boolean |
Greyed |
Calendar |
layout |
month-and-year, month-only, year-only |
Native selects in the header |
Calendar |
year-range |
DateValue[] |
Years in the year select. Defaults to 100 years back and 10 ahead, within min-value and max-value |
Calendar |
number-of-months |
number | Months side by side |
Calendar |
locale |
string | Weekday and month names, first day of the week |
Calendar |
initial-focus |
boolean | Focuses the picked day, or today, when shown. Use it in a popover |
Calendar |
slots calendar-heading, calendar-prev-icon, calendar-next-icon |
Replace the heading or the arrows |
The parts (CalendarCell, CalendarCellTrigger, CalendarGrid, CalendarHeader, CalendarHeading, CalendarHeadCell, CalendarPrevButton, CalendarNextButton and the grid rows) are exported for a custom layout.
Built on
Wraps the reka-ui Calendar with the shadcn-vue Calendar API. reka-ui gives the grid roles, keyboard movement, locale handling and the disabled and unavailable rules. Beehexa adds the styles. Days use the Beehexa Subtle button styles; the month and year pickers are the Beehexa Native select.
Limitations
- The month and year selects show the short name drawn over a select whose own text is transparent, as shadcn-vue does.