Calendar
Web/MobileA date picker calendar for selecting a day, several days, or a range.
| ش | ۱ش | ۲ش | ۳ش | ۴ش | ۵ش | ج |
|---|---|---|---|---|---|---|
Installation
pnpm dlx cubix-ui@latest add calendar --base radixUsage
import * as React from "react"
import { faIR } from "react-day-picker/locale"
import { Calendar } from "@/components/cubix/calendar"
<Calendar
mode="single"
selected={date}
onSelect={setDate}
locale={faIR}
dir="rtl"
numerals="arabext"
className="rounded-lg border"
/>
Composition
Calendar wraps React DayPicker and styles nav and day cells with the Cubix Button of each base. Pass locale={faIR}, dir="rtl" and numerals="arabext" for Persian labels and digits. Range corners and chevrons use logical properties and cn-rtl-flip. For the Persian Solar Hijri calendar, install @daypicker/persian and swap the DayPicker import in calendar.tsx.
Calendar
└── DayPicker (locale, dir, numerals)Accessibility
Day cells are buttons. Arrow keys move through the grid, Enter or Space selects, and the previous/next month controls are named by DayPicker. Set timeZone on the client when the highlighted day looks one day off.
Examples
Range
Use mode="range" with numberOfMonths={2} to pick a start and end date across two months.
| ش | ۱ش | ۲ش | ۳ش | ۴ش | ۵ش | ج |
|---|---|---|---|---|---|---|
| ش | ۱ش | ۲ش | ۳ش | ۴ش | ۵ش | ج |
|---|---|---|---|---|---|---|
Month and year selector
Set captionLayout="dropdown" to jump months and years from the caption.
| ش | ۱ش | ۲ش | ۳ش | ۴ش | ۵ش | ج |
|---|---|---|---|---|---|---|
Booked dates
Disable dates and mark them with modifiers for a booked look.
| ش | ۱ش | ۲ش | ۳ش | ۴ش | ۵ش | ج |
|---|---|---|---|---|---|---|
Week numbers
Use showWeekNumber to show ISO week numbers in a leading column.
| ش | ۱ش | ۲ش | ۳ش | ۴ش | ۵ش | ج | |
|---|---|---|---|---|---|---|---|
۴۰ | |||||||
۴۱ | |||||||
۴۲ | |||||||
۴۳ | |||||||
۴۴ | |||||||
۴۵ |
Date picker
Compose Calendar with Popover to build a date picker field.
Timezone
Pass timeZone from the client so the selected day matches the user's local timezone and hydration stays stable.
| ش | ۱ش | ۲ش | ۳ش | ۴ش | ۵ش | ج |
|---|---|---|---|---|---|---|
در حال تشخیص منطقه زمانی...
API Reference
Note: The root renders data-slot="calendar". Calendar forwards React DayPicker props. Use the same props on Base UI, React Aria, and Radix.
Calendar
| Prop | Type | Default | Description |
|---|---|---|---|
| mode | "single" | "multiple" | "range" | "single" | Selection mode for one date, several dates, or a range. |
| selected | Date | 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. |
| numberOfMonths | number | 1 | How many months to show side by side. |
| showWeekNumber | boolean | false | Show ISO week numbers in a leading column. |
| showOutsideDays | boolean | true | Show days from the previous and next months. |
| buttonVariant | "default" | "foreground" | "secondary" | "gray" | "destructive" | "destructive-secondary" | "outline" | "ghost" | "link" | "ghost" | Visual style of the previous and next month buttons. |
| locale | Locale | - | Locale from react-day-picker/locale for weekday labels and formatting. |
| dir | "ltr" | "rtl" | - | Reading direction for the grid, captions, and nav chevrons. |
| numerals | "latn" | "arab" | "arabext" | string | "latn" | Numbering system for day and year digits. Use arabext for Persian digits. |
| timeZone | string | - | IANA timezone used to display and select dates. Set this on the client to avoid hydration mismatches. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |