RegistryInstall CalendarCN with the shadcn CLI

Components

Calendar List

The calendars of the sidebar, grouped by account, each with a show and hide button.

Hover a calendar and click its eye to hide it

Calendar List is the list of calendars in the Calendar Sidebar. Calendars are grouped under their account's email, each account collapsible, each calendar with its color. Hover a calendar to show its eye button and hide it; a subscribed calendar, like a holidays feed, gets a feed icon.

Installation

pnpm dlx shadcn add @calendarcn/calendar-list

Usage

The list lists the calendars of the surrounding CalendarProvider, the same ones the event details' calendar picker offers. It's built from shadcn/ui's sidebar parts, so it needs a SidebarProvider around it.

import { CalendarList } from "@/components/calendar-list";
import type { CalendarInfo } from "@/components/calendar-types";

const calendars: CalendarInfo[] = [
  {
    id: "personal",
    name: "Personal",
    color: "purple",
    email: "you@example.com",
  },
  {
    id: "holidays",
    name: "Holidays",
    color: "green",
    email: "you@example.com",
    isSubscribed: true,
  },
  { id: "work", name: "Work", color: "blue", email: "you@work.example.com" },
];

<CalendarProvider defaultEvents={events} calendars={calendars}>
  <SidebarProvider>
    <CalendarList />
  </SidebarProvider>
</CalendarProvider>;

Outside a provider, pass calendars yourself. Hiding a calendar only dims its row: read the hidden ids with onHiddenCalendarIdsChange to filter your events, or set them with hiddenCalendarIds.

const [hidden, setHidden] = React.useState<string[]>([]);

<CalendarList
  calendars={calendars}
  hiddenCalendarIds={hidden}
  onHiddenCalendarIdsChange={setHidden}
/>;

API Reference

CalendarList

PropTypeDefault
calendars
Calendars to list, grouped under their account email. Defaults to the calendars of the nearest CalendarProvider.
CalendarInfo[]–
hiddenCalendarIds
Ids of the hidden calendars (controlled).
string[]–
defaultHiddenCalendarIds
Ids of the calendars hidden at first (uncontrolled).
string[][]
onHiddenCalendarIdsChange
Called with the new hidden ids when a calendar is shown or hidden.
(hiddenCalendarIds: string[]) => void–

CalendarInfo

The list reads these fields of each calendar (from @/components/calendar-types):

FieldType
id (required)
What hiddenCalendarIds holds.
string
name (required)
Shown in the row.
string
color (required)
The row's swatch.
EventColor
email
Account the calendar is listed under. Calendars without one are listed under "Calendars".
string
isSubscribed
A calendar followed rather than owned, like a holidays feed. Its swatch gets a feed icon.
boolean

On this page