1. Docs
  2. Components
  3. Calendar

Calendar

A calendar displays one or more date grids and allows users to select a single date.

Installation

npx shadcn@latest add @kanpeki/calendar

Usage

Single import

import { Button } from "~/components/ui/button";
import { Calendar } from "~/components/ui/calendar";
<Calendar.Root>
  <Calendar.Header>
    <Calendar.Nav>
      <Button slot="previous"></Button>
      <Calendar.Month />
      <Button slot="next"></Button>
    </Calendar.Nav>
  </Calendar.Header>

  <Calendar.Grid>
    <Calendar.GridHeader>
      {(weekDay) => <Calendar.HeaderCell>{weekDay}</Calendar.HeaderCell>}
    </Calendar.GridHeader>
    <Calendar.GridBody>
      {(date) => <Calendar.Cell date={date} />}
    </Calendar.GridBody>
  </Calendar.Grid>
</Calendar.Root>

Multiple imports

import { Button } from "~/components/ui/button";
import {
  CalendarCell,
  CalendarGrid,
  CalendarGridBody,
  CalendarGridHeader,
  CalendarHeader,
  CalendarHeaderCell,
  CalendarMonth,
  CalendarNav,
  CalendarRoot,
} from "~/components/ui/calendar";
<CalendarRoot>
  <CalendarHeader>
    <CalendarNav>
      <Button slot="previous"></Button>
      <CalendarMonth />
      <Button slot="next"></Button>
    </CalendarNav>
  </CalendarHeader>

  <CalendarGrid>
    <CalendarGridHeader>
      {(weekDay) => <CalendarHeaderCell>{weekDay}</CalendarHeaderCell>}
    </CalendarGridHeader>
    <CalendarGridBody>
      {(date) => <CalendarCell date={date} />}
    </CalendarGridBody>
  </CalendarGrid>
</CalendarRoot>

Examples

Default

Range