RegistryInstall CalendarCN with the shadcn CLI

Components

Month View

A month at a glance.

Month View shows six weeks at a time. Timed events are listed in each day, all-day and multi-day events run across days as bars, and busy days collapse the rest into a "more" button. Like every view, it reads its state from the surrounding CalendarProvider.

Installation

pnpm dlx shadcn add @calendarcn/month-view

Usage

import { CalendarProvider } from "@/components/calendar-provider";
import { MonthView } from "@/components/month-view";

export function MonthlyPlan() {
  return (
    <CalendarProvider defaultView="month" defaultEvents={events}>
      {/* Month View fills its parent's height */}
      <div className="h-[600px]">
        <MonthView />
      </div>
    </CalendarProvider>
  );
}

Set defaultView="month" (or control view) so the provider snaps the date, header and navigation to months. To switch between month and week, see the Calendar example.

Features

  • Drag an event to another day, or drag the ends of a bar to change its dates.
  • Double-click a day's empty space to create an all-day event, or press and drag across days to draw one over them. See Creating events.
  • "N more" on a busy day calls showDay(), which switches the provider to the week view and briefly highlights that day. Render Week View for that view, as the Calendar example does; with Month View alone the button has nothing to show.
  • Scroll vertically to move through weeks. Scrolling snaps to the nearest week.
  • Hide weekends, show week numbers or hide the events you declined through the provider's view settings. Declined events are struck through while they show.
  • Move a focused event a day with Alt← / Alt→, or a week with Alt↑ / Alt↓. See Keyboard & accessibility.

Scrolling over the preview

Month View turns vertical wheel scrolling into week navigation, so the page doesn't scroll while the pointer is over it. Scroll beside the preview to move down the page.

API Reference

MonthView

Everything else (date, events, week start, locale, view settings) is set on CalendarProvider.

PropTypeDefault
showEventPopover
Whether the selected event opens a details popover beside it. Turn it off when the details are shown elsewhere, such as a side panel.
booleantrue
onEventPopoverExpand
Called by the popover's expand button, e.g. to move the details into a side panel. The button is hidden when this is not set.
() => void–
className
Classes for the root element.
string–

On this page