Calendar

A calendar component that allows users to select a date or a range of dates.

September 2026

Installation

pnpm dlx cubix@latest add calendar

Usage

Import
import { Calendar } from "@/components/cubix/calendar"
Example
const [date, setDate] = React.useState<Date | undefined>(new Date())

return (
  <Calendar
    mode="single"
    selected={date}
    onSelect={setDate}
    className="rounded-lg border"
  />
)

About

The Calendar is built on React DayPicker. See the DayPicker docs for the full prop surface.

Examples

Basic

A single-date calendar. rounded-lg border gives it a panel look.

September 2026

Range Calendar

Use mode="range" to select a start and end date.

September 2026
October 2026

Month and Year Selector

Set captionLayout="dropdown" to jump months and years.

September 2026

Booked dates

Disable dates and mark them with modifiers for a booked look.

February 2026

Week Numbers

Use showWeekNumber to show week numbers.

September 2026
36
37
38
39
40

Date picker

Compose Calendar with Popover to build a date picker field.

Persian / Jalali

To use the Persian calendar, import DayPicker from react-day-picker/persian instead of react-day-picker in calendar.tsx.

 
import { DayPicker } from "react-day-picker/persian"

Selected Date (With TimeZone)

Pass timeZone from the client so the selected day matches the user's local timezone.

 
const [date, setDate] = React.useState<Date | undefined>(undefined)
const [timeZone, setTimeZone] = React.useState<string | undefined>(undefined)

React.useEffect(() => {
  setTimeZone(Intl.DateTimeFormat().resolvedOptions().timeZone)
}, [])

return (
  <Calendar
    mode="single"
    selected={date}
    onSelect={setDate}
    timeZone={timeZone}
  />
)

API Reference

Note: Calendar forwards React DayPicker props. Set timeZone on the client if the highlighted day looks one day off.

Calendar

The calendar that lets users pick a date or a range of dates.

PropTypeDefaultDescription
mode"single" | "multiple" | "range""single"Selection mode for one date, several dates, or a range.
selectedDate | Date[] | DateRange-The selected date, dates, or range.
onSelect(date) => void-Called when the selection changes.
captionLayout"label" | "dropdown" | "dropdown-months" | "dropdown-years""label"Month caption as text or month/year dropdowns.
numberOfMonthsnumber1How many months to show side by side.
showWeekNumberbooleanfalseShow ISO week numbers in a leading column.
showOutsideDaysbooleantrueShow days from the previous and next months.
buttonVariant"default" | "secondary" | "destructive" | "outline" | "ghost" | "link""ghost"Visual style of the previous and next month buttons.
localeLocale-Locale from react-day-picker/locale for labels and RTL.
timeZonestring-IANA timezone used to display and select dates. Set this on the client to avoid hydration mismatches.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).