You selected: Thu Apr 24 2025

Calendar Component

A highly customizable calendar component based on react-day-picker with advanced date selection capabilities.

  • Multiple selection modes: single, multiple, range
  • Supports day, month, quarter, and year views
  • Fully accessible with ARIA attributes
  • Customizable styling through classNames

Installation

The Calendar component is part of our UI library. You can import it directly from the components directory.


Usage

Here is how to use the calendar in your project.

React TSX
1import { Calendar } from "@/components/modern-ui/calendar"

React TSX
1<Calendar mode="single" />

Examples

Default Calendar

Date Range Selection

Multiple Date Selection


API Reference

Main Props

PropTypeDefaultDescription
mode"single" | "multiple" | "range" | "custom""single"Selection mode of the calendar
selectedDate | Date[] | DateRange | undefinedundefinedCurrently selected date(s)
onSelect(date: Date | Date[] | DateRange | undefined) => voidundefinedHandler called when date(s) are selected
defaultMonthDateCurrent monthThe default month to display
initialView"days" | "months" | "years""days"The initial view to display when calendar opens
showOutsideDaysbooleantrueWhether to show days from previous/next months
showYearSwitcherbooleantrueWhether to show the year switcher in the caption
yearRangenumber12Number of years to display in the year view
numberOfMonthsnumber1Number of months to display at once
disabledDate[] | ((date: Date) => boolean)undefinedDates to disable or a function to determine if a date should be disabled
fromDateDateundefinedMinimum date that can be selected
toDateDateundefinedMaximum date that can be selected

Event Handlers

PropTypeDescription
onMonthSelect(date: Date) => voidHandler called when a month is selected
onQuarterSelect(date: Date) => voidHandler called when a quarter is selected
onYearSelect(date: Date) => voidHandler called when a year is selected
onDayClick(date: Date, modifiers: DayModifiers, e: MouseEvent) => voidHandler called when a day is clicked
onMonthChange(month: Date) => voidHandler called when the month changes

Styling Props

The Calendar component provides extensive styling options through className props:

PropDescription
classNameThe main Calendar container class
monthsClassNameThe months container class
monthCaptionClassNameThe month caption class
weekdaysClassNameThe weekdays container class
weekdayClassNameThe weekday class
monthClassNameThe month class
captionClassNameThe caption class
captionLabelClassNameThe caption label class
buttonNextClassNameThe next button class
buttonPreviousClassNameThe previous button class
navClassNameThe navigation class
monthGridClassNameThe month grid class
weekClassNameThe week class
dayClassNameThe day class
dayButtonClassNameThe day button class
rangeStartClassNameThe range start day class
rangeEndClassNameThe range end day class
selectedClassNameThe selected day class
todayClassNameThe today day class
outsideClassNameThe outside day class
disabledClassNameThe disabled day class
rangeMiddleClassNameThe middle day in a range class
hiddenClassNameThe hidden day class