# Calendar

A date field component that allows users to enter and edit dates.

> For the complete documentation index, see [llms.txt](/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](/.well-known/agent-skills/site-skill.md).





<ComponentPreview name="calendar-demo">
  <CalendarDemo />
</ComponentPreview>

## Installation [#installation]

<Tabs defaultValue="cli">
  <TabsList>
    <TabsTrigger value="cli">
      CLI
    </TabsTrigger>

    <TabsTrigger value="manual">
      Manual
    </TabsTrigger>
  </TabsList>

  <TabsContent value="cli">
    ```bash
    npx shadcn@latest add https://shadcn-cssinjs.com/r/calendar.json
    ```
  </TabsContent>

  <TabsContent value="manual">
    <Steps>
      <Step>
        Install the following dependencies:
      </Step>

      ```bash
      pnpm add react-day-picker date-fns @stylexjs/stylex
      ```

      <Step>
        Make sure [StyleX is configured](/docs/installation) and the design tokens are
        installed.
      </Step>

      <Step>
        Copy and paste the following code into your project.
      </Step>

      <ComponentSource name="calendar" title="calendar.tsx" />

      <Step>
        Update the import paths to match your project setup.
      </Step>
    </Steps>
  </TabsContent>
</Tabs>

## Usage [#usage]

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

```tsx
<Calendar mode="single" selected={date} onSelect={setDate} />
```

## Examples [#examples]



### Basic [#basic]

<ComponentPreview name="calendar-demo">
  <CalendarDemo />
</ComponentPreview>

### Range Calendar [#range-calendar]

Use `mode="range"` to select a range of dates.

<ComponentPreview name="calendar-range">
  <CalendarRange />
</ComponentPreview>

### Month and Year Selector [#month-and-year-selector]

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

<ComponentPreview name="calendar-caption">
  <CalendarCaption />
</ComponentPreview>

### Presets [#presets]

<ComponentPreview name="calendar-presets">
  <CalendarWithPresets />
</ComponentPreview>

### Booked dates [#booked-dates]

Use `disabled` and `modifiers` to mark booked dates.

<ComponentPreview name="calendar-booked-dates">
  <CalendarBookedDates />
</ComponentPreview>

### Week Numbers [#week-numbers]

Use `showWeekNumber` to display week numbers.

<ComponentPreview name="calendar-week-numbers">
  <CalendarWeekNumbers />
</ComponentPreview>



## RTL [#rtl]

To enable right-to-left support, see the [RTL guide](/docs/rtl).

<ComponentPreview name="calendar-rtl" direction="rtl">
  <CalendarRtl />
</ComponentPreview>

## API Reference [#api-reference]

The `Calendar` component is built on top of [React DayPicker](https://daypicker.dev). See the [React DayPicker documentation](https://daypicker.dev) for the full list of props.
