Components

Calendar

A versatile and customizable calendar component for Nuxt UI, supporting date and range selection, time picking, and i18n.

The ProCalendar component is a versatile and reusable calendar for Nuxt applications, built with Nuxt UI and dayjs. It supports single date, multiple dates, and range selection, time picking, internationalization, and extensive customization.

Example

Here's an example of the ProCalendar in action:

Learn how to use the Nuxt Charts CLI to get premium components.

Props

PropTypeDefaultDescription
selectionMode'single' | 'range' | 'multiple''single'The selection mode for dates.
initialDateDateundefinedThe initially selected date (for single and multiple modes).
initialStartDateDateundefinedThe initially selected start date (for range mode).
initialEndDateDateundefinedThe initially selected end date (for range mode).
showTimePickerbooleanfalseIf true, the time picker is displayed.
timeSlotsstring[]['09:00', ...]An array of time slots to display in the time picker.
initialTimestringundefinedThe initially selected time.
dateFormatstring'dddd, MMMM D, YYYY'The format for displaying selected dates.
timeFormatstring'HH:mm'The format for displaying selected times.
weekDayLabels[string, string, string, string, string, string, string]['Sun', 'Mon', ...]An array of labels for the days of the week.
orientation'vertical' | 'horizontal''horizontal'The orientation of the calendar and time picker.
visibleMonthsnumber1The number of months to display at once.
localestring'en'The locale for dayjs (e.g., 'en', 'es', 'fr').
disabledDatesDate[]undefinedAn array of dates to disable.
minDateDateundefinedThe minimum selectable date.
maxDateDateundefinedThe maximum selectable date.
classNamesobject{}An object with classes to customize the calendar's appearance.

Events

EventPayloadDescription
date-selectDate | Date[]Emitted when a date is selected. The payload is a Date object in single mode and an array of Date objects in multiple mode.
range-select{ start: Date | null, end: Date | null }Emitted when a date range is selected in range mode.
time-selectstringEmitted when a time is selected from the time picker.
month-changeDayjsEmitted when the displayed month changes. The payload is a dayjs object.
year-changenumberEmitted when the displayed year changes.

Styling

You can customize the calendar's appearance by passing a classNames object with the following keys:

  • container: The main container of the calendar.
  • header: The header section with the month and navigation buttons.
  • weekdays: The container for the weekday labels.
  • day: A single day in the calendar grid.
  • today: A class for the current day.
  • selected: A class for selected dates.
  • disabled: A class for disabled dates.
  • inRange: A class for dates within a selected range.

Example:

<template>
  <ProCalendar :class-names="customClasses" />
</template>

<script setup lang="ts">
const customClasses = {
  header: 'bg-gray-200 dark:bg-gray-800',
  selected: '!bg-green-500 text-white',
}
</script>

Internationalization (i18n)

To use the calendar in different locales, import the desired locale from dayjs and pass the locale prop. For example, for Spanish:

<script setup>
import 'dayjs/locale/es'
</script>

<template>
  <ProCalendar locale="es" />
</template>
<template>
  <Calendar />
</template>