---
title: Calendar
description: A date field component that allows users to enter and edit date.

link:
  doc: https://corvu.dev/docs/primitives/calendar/
  api: https://corvu.dev/docs/primitives/calendar/#api-reference
---

<ComponentPreview name="calendar-demo">

```tsx file=<rootDir>/apps/docs/src/registry/examples/calendar-demo.tsx

```

</ComponentPreview>

## Installation

<ComponentInstallation>

<Step>

<StepItem>Copy and paste the following code into your project:</StepItem>

  <ComponentSourceTabs>

    ```tsx title="components/ui/calendar" file=<rootDir>/apps/docs/src/registry/ui/calendar.tsx

    ```

    ```tsx title="components/ui/calendar" file=<rootDir>/apps/unocss-playground/src/registry/ui/calendar.tsx

    ```

  </ComponentSourceTabs>

</Step>

</ComponentInstallation>

## Usage

```tsx
import {
  Calendar,
  CalendarCell,
  CalendarCellTrigger,
  CalendarHeadCell,
  CalendarLabel,
  CalendarNav,
  CalendarTable,
} from "@components/ui/calendar"
```

```tsx
<Calendar mode="single">
  {(props) => (
    <>
      <CalendarNav action="prev-month" />
      <CalendarLabel />
      <CalendarNav action="next-month" />
      <CalendarTable>
        <thead>
          <tr class="flex">
            <Index each={props.weekdays}>
              {(weekday) => <CalendarHeadCell />}
            </Index>
          </tr>
        </thead>
        <tbody>
          <Index each={props.weeks}>
            {(week) => (
              <tr>
                <Index each={week()}>
                  {(day) => (
                    <CalendarCell>
                      <CalendarCellTrigger day={day()} />
                    </CalendarCell>
                  )}
                </Index>
              </tr>
            )}
          </Index>
        </tbody>
      </CalendarTable>
    </>
  )}
</Calendar>
```

## Examples

### Range Calendar

<ComponentPreview name="calendar-range-demo">

```tsx file=<rootDir>/apps/docs/src/registry/examples/calendar-range-demo.tsx

```

</ComponentPreview>
