Calendar View
Data · CalendarView
A full calendar: day, week, month and agenda, for several calendars at once.
- Calendars: each with a tint and a visibility toggle (
hidden/onHiddenChange);readOnlycalendars such as public holidays show without reply or actions. - Day and week: an all-day row, hours from
hours(widened to fit the events), overlapping events side by side and a line at the current time. - Creating: click an empty slot (an hour), drag over a range (snapped to 15 minutes) or press Enter on a focused slot;
onCreategets{ start, end, allDay }. Arrow keys move between slots and days, Home/End to the first and last hour. - Details: a popover next to the event on desktop and a sheet from the bottom on phones, with place, calendar, description, guests and their replies, "Going?" (
onRsvp) and your own buttons (eventActions). - Phones: under 640 px a week or month shows as a list of days (the agenda).
- Controlled:
view,date,selected,hidden;onRangeChangereports the visible range (also on mount) so you can load its events. - Weekday and month names, times and ranges come from
Intlin the provider's locale;weekStartsOn={0}starts weeks on Sunday.
All day
Props
CalendarView
| Prop | Type | Notes |
|---|---|---|
events | CalendarEvent[] | Required |
calendars? | CalendarDef[] | Calendars with colour and a visibility toggle each. |
hidden? | string[] | Ids of hidden calendars (controlled) / initially hidden / on toggle. |
defaultHidden? | string[] | |
onHiddenChange? | (ids: string[]) => void | |
view? | CalendarViewMode | Day, week, month or agenda (default week). On phones a week or month shows as a list. |
defaultView? | CalendarViewMode | |
onViewChange? | (view: CalendarViewMode) => void | |
date? | Date | The day the view shows (controlled) / initially (default today). |
defaultDate? | Date | |
onDateChange? | (date: Date) => void | |
onRangeChange? | (range: { start: Date; end: Date; view: CalendarViewMode }) => void | The visible range changed (also on mount): load its events. `end` is exclusive. |
views? | CalendarViewMode[] | The views offered in the switcher (default all four). |
onCreate? | (slot: { start: Date; end: Date; allDay: boolean }) => void | Click or drag on an empty slot (or Enter on a focused slot): the new event's time. |
selected? | string | null | The event whose details are open (controlled) / initially / on open and close. |
defaultSelected? | string | null | |
onSelectedChange? | (id: string | null) => void | |
onOpenEvent? | (event: CalendarEvent) => void | Called when an event's details open. |
onRsvp? | (event: CalendarEvent, rsvp: CalendarRsvp) => void | Your answer from the details (Yes, Maybe, No) for events with `rsvp`. |
eventActions? | (event: CalendarEvent) => ReactNode | Buttons at the bottom of the details (Edit, Delete, Open). |
hours? | [number, number] | First and last hour of the day and week grid (default 7 to 21; widened to fit events). |
weekStartsOn? | 0 | 1 | 1 = Monday (default), 0 = Sunday. |
maxPerDay? | number | Most events per day in the month (default 3, then "+2 more"). |
title? | string | Heading instead of the date range. |
toolbar? | ReactNode | More controls at the end of the toolbar (a "New event" button). |
now? | Date | string | number | What counts as now (default the clock), for stable tests and server rendering. |
className? | string | Extra class on the root element. |
style? | CSSProperties | Inline style on the root element. |