Installation
Usage
"use client"
import { EventCalendar } from "@/components/event-calendar"
export function TeamCalendar() {
return (
<EventCalendar
label="Team calendar"
defaultDate="2026-11-11"
resources={[
{ id: "atlas", title: "Atlas", meta: "8 seats" },
{ id: "harbor", title: "Harbor", meta: "4 seats" },
]}
defaultEvents={[
{ id: "review", title: "Design review", start: "2026-11-11T10:00", end: "2026-11-11T11:30", resource: "atlas", people: ["Emily Carter"] },
{ id: "sync", title: "Roadmap sync", start: "2026-11-11T10:30", end: "2026-11-11T11:00", resource: "harbor" },
{ id: "offsite", title: "Team offsite", allDay: true, start: "2026-11-13" },
]}
onEventsChange={(events, change) => console.log(change.type, change.event)}
/>
)
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| events / defaultEvents | CalendarEvent[] | [] | Kept by you or by the component. An event has id, title, start and end as wall-clock strings ("2026-11-11T09:30", or dates for allDay), and optional color, resource, people and location. |
| onEventsChange | (events, change) => void | — | Called after every create, move, resize, rename, recolour or delete, with the change (type, event, previous) so you can save just that one. |
| view / defaultView | "week" | "day" | "month" | "resources" | "week" | The view, kept by you or by the component. onViewChange tells you when it changes. |
| date / defaultDate | string | today | The day in view, "2026-11-11". onDateChange tells you when it changes. |
| resources | CalendarResource[] | [] | Columns of the resources view (id, title, meta): rooms, people or machines booked side by side. resourcesLabel names the view ("Rooms"). |
| label | string | — | Accessible name. |
| canChange | (change) => boolean | — | Veto a change, for example a room that is already booked. |
| readOnly | boolean | false | Look and open events, but no creating, moving or deleting. |
| hours / scrollToHour | [number, number] / number | [0, 24] / 8 | The hours shown, and where the day scrolls to when it opens. |
| snapMinutes / hourHeight | number | 15 / 48 | What drags and keyboard moves snap to, and pixels per hour. |
| weekStartsOn / locale | 0 | 1 / string | 1 / "en-US" | Sunday or Monday first, and how dates and times are written. |
| colors | string[] | five tints | The colours offered in an event's details; new events take the first. |
| renderDetails | (event) => ReactNode | — | Extra content in an event's details card, like a join link. |
Accessibility
- Every event is a button named with its title, day, time and room; Enter opens its details as a dialog, and Escape closes it and gives focus back.
- Alt and Up or Down move an event by the snap, Alt Shift Up or Down change its length, Alt Left or Right move it a day or to the next room, Delete removes it.
- Every change is announced through a polite live region, and Ctrl or Cmd Z or the toast's Undo takes it back.
- Week, Day, Month and Rooms are tabs: Left and Right move between them; T goes to today and D, W, M and R switch views while the calendar has focus.
- Dates and times come from the strings you pass, with no time zone, so the server and every browser render the same calendar.
- On touch, press and hold creates or picks up an event, so a swipe still scrolls.
- Under prefers-reduced-motion views, cards and the toast appear without moving.
Changelog
- v1.0.0Latest
First release.
- v1.1.0
No longer needs the motion package: the view pill glides on the same spring with the browser's Web Animations.
- v1.0.1
Dates and times that can't be read no longer break the calendar: it opens on today and leaves those events out.