Xzero UI
Pro library

Week calendarPro

A week calendar where you drag to create, move, and resize events, with color coded calendars, day and agenda views, and swipes on phones.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/week-calendar
Live · keyboard ready

Use this for scheduling and planning views. Pass your events and calendars, and persist changes in onCreate, onUpdate, and onDelete.

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/week-calendar

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { useState } from "react";
import { WeekCalendar, type CalendarEvent } from "@/components/xzero/blocks/week-calendar/week-calendar";

const calendars = [
  { id: "work", name: "Work", color: "blue" },
  { id: "personal", name: "Personal", color: "green" },
];

export default function SchedulePage({ initial }: { initial: CalendarEvent[] }) {
  const [events, setEvents] = useState(initial);
  return (
    <WeekCalendar
      events={events}
      onEventsChange={setEvents}
      calendars={calendars}
      onCreate={event => api.create(event)}
      onUpdate={event => api.update(event)}
      onDelete={event => api.remove(event.id)}
      startHour={6}
      timeZone="America/Los_Angeles"
    />
  );
}

API reference

WeekCalendar

A week calendar at the level of a native app: week, work week and day views on wide screens, three days and an agenda list on phones, a mini month and calendar toggles in a sidebar when there is room, and an all day row that collapses when it fills up. Drag on empty time to draw an event and name it in a quick create popover, drag events between days and times, stretch the bottom edge to resize, and click an event to edit its title, day, time and calendar; everything snaps to 15 minutes. Events can be controlled or uncontrolled; without events it shows a realistic sample week.

PropTypeDefaultDescription
eventsCalendarEvent[]–Controlled events: { id, title, start: Date, end: Date, calendarId, allDay?, location?, attendees? }. Pair with onEventsChange.
defaultEventsCalendarEvent[]–Starting events when uncontrolled. Without events or defaultEvents the calendar shows the sample week from week-calendar-data.ts.
onEventsChange(events: CalendarEvent[]) => void–Called with the full list after every change: create, move, resize, edit, delete and undo.
onCreate(event: CalendarEvent) => void–Called when someone saves a new event, and when an undo restores a deleted one.
onUpdate(event: CalendarEvent, previous: CalendarEvent) => void–Called after a move, resize or edit in the details popover, with the event before the change.
onDelete(event: CalendarEvent) => void–Called when an event is deleted. The undo toast calls onCreate if the person restores it.
calendarsCalendarSource[]SAMPLE_CALENDARSCalendars as { id, name, color, hidden? }. color is blue, green, violet, amber, rose, teal or any CSS color; built in names are tuned for light and dark.
defaultDateDate–The day to open on. Defaults to today, or to the sample week when showing sample events.
defaultView"week" | "workweek" | "day" | "3day" | "agenda""week"Starting view. Below a 640px container week views show three days, and agenda is offered instead of work week.
onViewChange(view: CalendarView) => void–Called when the view changes.
weekStartsOn0 | 1 | 2 | 3 | 4 | 5 | 61First day of the week; 0 is Sunday.
startHournumber0First hour shown in the day grid.
endHournumber24Hour the day grid ends at.
timeZonestring–IANA zone the grid runs in, such as "America/New_York". Times are converted and formatted with Intl. Defaults to the browser's zone.
localestring"en-US"Locale for dates and times.
classNamestring–Class for the root element. Set --calendar-height on it to change the height of the scrolling grid.

Keyboard interactions

KeysAction
Arrow left / Arrow rightMoves between days; past the edge of the range, the next week or days slide in.
TGoes to today.
NDrafts a new event at the next free hour of the focused day and opens the quick create form.
EnterSaves the quick create form, opens a focused event, or drafts an event on a focused day.
Delete / BackspaceDeletes the focused or selected event, with an undo toast.
EscapeCloses a popover, cancels a drag, or clears the selection.
D / WSwitches to the day or week view.
Arrow up / Arrow downOn an event, moves focus to the previous or next event.
Alt + Arrow keysMoves the focused event by a day or 15 minutes; add Shift with up and down to change its length.
Cmd / Ctrl + ZUndoes the last move, resize, time change or delete.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Guidance for AI tools

Blocks are complete, self-contained screens with sample data. Replace the sample data and connect the callbacks described above. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components