Components
Calendar List
The calendars of the sidebar, grouped by account, each with a show and hide button.
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-listUsage
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
| Prop | Type | Default |
|---|---|---|
calendarsCalendars to list, grouped under their account email. Defaults to the calendars of the nearest CalendarProvider. | CalendarInfo[] | – |
hiddenCalendarIdsIds of the hidden calendars (controlled). | string[] | – |
defaultHiddenCalendarIdsIds of the calendars hidden at first (uncontrolled). | string[] | [] |
onHiddenCalendarIdsChangeCalled 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):
| Field | Type |
|---|---|
id (required)What hiddenCalendarIds holds. | string |
name (required)Shown in the row. | string |
color (required)The row's swatch. | EventColor |
emailAccount the calendar is listed under. Calendars without one are listed under "Calendars". | string |
isSubscribedA calendar followed rather than owned, like a holidays feed. Its swatch gets a feed icon. | boolean |