Skip to content
synccn

Event Calendar

New

Month view for events: timed and all-day chips, multi-day events, +N more, keyboard navigation and a day agenda. Dots on phones.

 

M
T
W
T
F
S
S

Pick a day to see its events

Arrow keys move between days; Page Up and Page Down change month.

Installation

$ pnpm dlx shadcn@latest add @synccn/event-calendar

First time in this project? Connect synccn with one command.

Usage

import { EventCalendar } from "@/components/ui/event-calendar";<EventCalendar events={events} onEventClick={open} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

EventCalendar

Month view for events: chips with times, multi-day events, "+N more", today, keyboard navigation between days and an agenda for the selected day. On phones, chips shrink to dots.

  • eventsrequired
    CalendarEvent[]

    —

  • defaultMonth
    Date

    Month shown first (any day in it). Defaults to the current month.

  • onMonthChange
    (month: Date) => void

    Called when the person moves to another month, with its first day.

  • onEventClick
    (event: CalendarEvent) => void

    Called when an event is chosen.

  • onDayClick
    (day: string, events: CalendarEvent[]) => void

    Called when a day is chosen, with a "YYYY-MM-DD" key and its events.

  • weekStartsOn
    0 | 1

    Default 1

    First day of the week: 0 is Sunday, 1 is Monday.

  • maxPerDay
    number

    Default 2

    Events shown in a day before "+N more".

  • timeZone
    string

    IANA time zone used to place events on days and format their times, e.g. "America/New_York". With it, events render on the server too; without it, they appear once the page loads in the browser's own time zone.

  • agenda
    boolean

    Default true

    Shows the selected day's events under the grid.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

  • lib/hooksuseIsClient (renders portals only in the browser), useNow (reads the current time in the browser)
  • lib/utilscn (merges class names)

npm packages

Keyboard

  • ←or→Previous or next day
  • ↑or↓Same day last or next week
  • Page UporPage DownSame day last or next month
  • EnterorSpaceSelect the day and show its agenda

Accessibility

  • Uses grid, row and gridcell roles; today has aria-current="date" and each day's label includes its event count.
  • Pass timeZone to render events on the server; without it they appear after load in the browser's time zone, so pages never hydrate with mismatched times.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: columnheader, grid, gridcell, row
  • ARIA attributes: aria-current, aria-label, aria-labelledby, aria-live, aria-selected
  • Keys handled: ArrowUp, ArrowDown, ArrowLeft, ArrowRight, PageUp, PageDown, Enter, Space
  • Shows a visible focus ring for keyboard users
  • Announces changes to screen readers