Event Calendar
React week and day event calendar: events placed by time, side by side overlaps, an all-day row, a live time line and click or keyboard to create events.
Installation
npx shadcn@latest add @minidev/event-calendar
MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/event-calendar.json
Usage
import { EventCalendar } from "@/components/ui/event-calendar"
export function Example() {
return (
<EventCalendar />
)
}
API reference
| Prop | Type | Default |
|---|---|---|
| eventsEvents to place. Defaults to a sample Lumen work week around today. | CalendarEvent[] | - |
| calendarsCalendars that colour events and fill the legend. | CalendarSource[] | CALENDARS |
| viewControlled view. | CalendarView | - |
| defaultView"auto" picks Day under 600px of width and Week above. | CalendarView | "auto" | "auto" |
| onViewChangeCalled when the Week/Day control or a day header changes the view. | (view: CalendarView) => void | - |
| defaultDateAny date inside the first week or day shown. Defaults to today. | Date | - |
| onDateChange | (date: Date) => void | - |
| weekStartsOn0 for Sunday, 1 for Monday. | 01 | 1 |
| scrollToHourHour the grid scrolls to on mount. | number | 8 |
| hourHeightPixel height of one hour row. | number | 48 |
| heightPixel height of the scrolling time grid. | number | 520 |
| slotMinutesMinutes a click on an empty slot snaps to. | number | 30 |
| onCreateCalled when an empty slot is clicked or chosen with the keyboard. | (range: { start: Date; end: Date }) => void | - |
| onEventClickCalled when an event block is clicked or activated with the keyboard. | (event: CalendarEvent) => void | - |
| localeBCP 47 locale for dates and times, e.g. "en-GB". | string | "en-US" |
| className | string | - |
When to use
Use for meeting and shift schedules. Events are plain objects with Date start and end; calendars set their colours. Click an empty slot (or focus a day column and use Up/Down then Enter) to fire onCreate. For a month grid use CalendarMonth; for a list of upcoming events use CalendarAgenda; for project timelines use GanttChart.
Keyboard interactions
| Key | Action |
|---|---|
| Tab | Moves through the toolbar, the day headers, the all-day events, then one slot target per day column and its events. |
| ArrowDownorArrowUp | On a day column, moves the proposed start time by slotMinutes (30 by default). |
| EnterorSpace | On a day column, calls onCreate for the proposed time. On an event, calls onEventClick. |
| EnterorSpace | On a day header in week view, opens that day. |
Accessibility
- The heading has
aria-live="polite", so the new range is announced after Previous, Next or Today. Those buttons are labelled "Previous week" or "Next day" to match the view. - Each event is a button named with its title, date, time range, location and calendar, for example "Design review, Tuesday, November 17, 10:00 AM to 11:30 AM, Room Atlas, Northwind".
- Each day column is a
role="button"slot target whose name explains the arrow keys; a visually hidden live region reads the chosen time as it changes. - Hour labels, grid lines and the current-time line are
aria-hidden.
Frequently asked questions
Why doesn't a new event stay after I click a slot?
EventCalendar does not store events. A click calls onCreate with a one-hour { start, end } and shows a "New event" preview; add the event to the array you pass as events and it renders like the others.
Is there a month view or drag to move events?
No. It has week and day views only, and events can't be dragged or resized. For a month grid use CalendarMonth.
Can I control the date shown?
Only the view is controllable (view and onViewChange). The date starts at defaultDate and reports changes through onDateChange. To jump to a date from outside, change the component's key with a new defaultDate.
How do I show 24-hour times or start weeks on Sunday?
Pass locale="en-GB" (or any BCP 47 locale) for times and dates, and weekStartsOn={0} for Sunday. The default is Monday.
Dependencies
npm
Built from
Examples
Day view
defaultView picks the layout, scrollToHour sets where the grid starts and locale drives the time format.
Custom events and calendars
Events reference a calendar id for their colour; defaultDate opens the week that holds them.
Create and click handlers
onCreate receives the snapped range for an empty slot and onEventClick the event, with slotMinutes setting the snap.