For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
113

Calendar

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

September 2026
"use client";

import * as React from "react";

import { Calendar } from "@/components/ui/calendar";

Installation

$ pnpm dlx shadcn@latest add https://shadcn-cssinjs.com/r/calendar.json

Usage

import { Calendar } from "@/components/ui/calendar";
const [date, setDate] = React.useState<Date | undefined>(new Date());
 
return (
  <Calendar
    mode="single"
    selected={date}
    onSelect={setDate}
    className="rounded-lg border"
  />
);

See the React DayPicker documentation for more information.

About

The Calendar component is built on top of React DayPicker.

Date Picker

You can use the <Calendar> component to build a date picker. See the Date Picker page for more information.

Persian / Hijri / Jalali Calendar

To use the Persian calendar, edit components/ui/calendar.tsx and replace react-day-picker with react-day-picker/persian.

- import { DayPicker } from "react-day-picker"
+ import { DayPicker } from "react-day-picker/persian"
يونيو 2025
"use client";

import {
  ChevronDownIcon,
  ChevronLeftIcon,
  ChevronRightIcon,

Selected Date (With TimeZone)

The Calendar component accepts a timeZone prop to ensure dates are displayed and selected in the user's local timezone.

export function CalendarWithTimezone() {
  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}
    />
  );
}

Note: If you notice a selected date offset (for example, selecting the 20th highlights the 19th), make sure the timeZone prop is set to the user's local timezone.

Why client-side? The timezone is detected using Intl.DateTimeFormat().resolvedOptions().timeZone inside a useEffect to ensure compatibility with server-side rendering. Detecting the timezone during render would cause hydration mismatches, as the server and client may be in different timezones.

Basic

A basic calendar component. We used className="rounded-lg border" to style the calendar.

September 2026
"use client";

import { Calendar } from "@/components/ui/calendar";

export function CalendarBasic() {
  return <Calendar mode="single" className="rounded-lg border" />;

Range Calendar

Use the mode="range" prop to enable range selection.

January 2026
February 2026
"use client";

import { addDays } from "date-fns";
import * as React from "react";
import type { DateRange } from "react-day-picker";

Month and Year Selector

Use captionLayout="dropdown" to show month and year dropdowns.

September 2026
"use client";

import { Calendar } from "@/components/ui/calendar";

export function CalendarCaption() {
  return (

Presets

September 2026
"use client";

import { addDays } from "date-fns";
import * as React from "react";

import { Button } from "@/components/ui/button";

Date and Time Picker

September 2026
"use client";

import { Clock2Icon } from "lucide-react";
import * as React from "react";

import { Calendar } from "@/components/ui/calendar";

Booked dates

January 2026
"use client";

import * as React from "react";

import { Calendar } from "@/components/ui/calendar";
import { Card, CardContent } from "@/components/ui/card";

Custom Cell Size

December 2026
"use client";

import { addDays } from "date-fns";
import * as React from "react";
import type { DateRange } from "react-day-picker";

You can customize the size of calendar cells using the --cell-size CSS variable. You can also make it responsive by using breakpoint-specific values:

<Calendar
  mode="single"
  selected={date}
  onSelect={setDate}
  className="rounded-lg border [--cell-size:--spacing(11)] md:[--cell-size:--spacing(12)]"
/>

Or use fixed values:

<Calendar
  mode="single"
  selected={date}
  onSelect={setDate}
  className="rounded-lg border [--cell-size:2.75rem] md:[--cell-size:3rem]"
/>

Week Numbers

Use showWeekNumber to show week numbers.

January 2026
01
02
03
04
05
"use client";

import * as React from "react";

import { Calendar } from "@/components/ui/calendar";
import { Card, CardContent } from "@/components/ui/card";

RTL

To enable RTL support in shadcn/ui, see the RTL configuration guide.

See also the Hijri Guide for enabling the Persian / Hijri / Jalali calendar.

سبتمبر 2026
"use client";

import * as React from "react";
import { arSA, he } from "react-day-picker/locale";

import { useTranslation } from "@/components/language-selector";

When using RTL, import the locale from react-day-picker/locale and pass both the locale and dir props to the Calendar component:

import { arSA } from "react-day-picker/locale";
<Calendar
  mode="single"
  selected={date}
  onSelect={setDate}
  locale={arSA}
  dir="rtl"
/>;

API Reference

See the React DayPicker documentation for more information on the Calendar component.