# Event Calendar overview

> A framework-agnostic event calendar with month, week, day, agenda and year views, recurring events, time zones, iCalendar import and export, and drag-and-drop editing.

Birch UI Event Calendar shows events on a calendar the way people expect from desktop calendar apps: a month grid with multi-day bars, week and day time grids, an agenda list and a year overview. It suits team schedules, clinic appointments, class timetables, room bookings and field-service calendars.

It is written in plain TypeScript, renders to the DOM and has no framework or date-library dependency. Like every Birch UI component it follows the shared widget contract, so it works in any framework.

> **Event Calendar: Paid feature. Fully functional without a key; a license removes the watermark. Pricing: https://docs.birchui.com/getting-started/pricing.md**
>
> Birch UI Event Calendar is a commercial product: $299 per developer, a one-time purchase with free updates forever, unlimited apps and unlimited end users. It is also part of the planned Project Suite bundle. Without a license key every feature works and a small watermark is shown; on `localhost` the watermark is skipped while you develop.

**Live demo: Team calendar with recurring meetings** (runs on the HTML version of this page). Source of `demos/calendar-basic.ts`. Imports from `./_shared` and `./_scheduler-data` are sample data and small UI helpers used only by the docs.

```ts
import { createCalendar, type CalendarEvent, type ViewType } from '@birchui/calendar';
import { docsTheme, field, layout, onDocsThemeChange } from './_shared';

export const meta = { title: 'Team calendar with recurring meetings', height: 560 };

interface TeamEvent extends CalendarEvent {
  location?: string;
}

const VIEWS: ViewType[] = ['month', 'week', 'day', 'agenda', 'year'];

function at(day: number, hour: number, minute = 0): Date {
  return new Date(2026, 10, day, hour, minute);
}

function teamEvents(): TeamEvent[] {
  return [
    {
      id: 'standup',
      title: 'Service desk stand-up',
      start: at(2, 9),
      end: at(2, 9, 15),
      rrule: 'FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR',
      exdates: [at(26, 9)],
      color: '#2563eb',
      location: 'Room 2B',
    },
    {
      id: 'planning',
      title: 'Sprint planning',
      start: at(3, 14),
      end: at(3, 15, 30),
      rrule: 'FREQ=WEEKLY;INTERVAL=2;BYDAY=TU',
      color: '#7c3aed',
    },
    {
      id: 'maintenance',
      title: 'Database maintenance window',
      start: at(28, 22),
      end: at(29, 2),
      color: '#b45309',
    },
    { id: 'visit-1', title: 'Site visit: Kestrel Logistics', start: at(10, 10), end: at(10, 12, 30), color: '#0f766e' },
    { id: 'visit-2', title: 'Site visit: Oakridge Clinics', start: at(18, 13), end: at(18, 16), color: '#0f766e' },
    { id: 'review', title: 'Quarterly business review', start: at(20, 11), end: at(20, 12), color: '#be123c' },
    {
      id: 'holiday',
      title: 'Thanksgiving (office closed)',
      start: at(26, 0),
      end: at(28, 0),
      allDay: true,
      color: '#475569',
    },
  ];
}

export default function mount(el: HTMLElement): () => void {
  const { toolbar, body, status } = layout(el);
  const view = document.createElement('select');
  for (const name of VIEWS) view.add(new Option(name, name, name === 'month', name === 'month'));
  toolbar.append(
    field('View', view),
    'Drag or resize an event. Recurring meetings move one occurrence unless you hold Shift.',
  );

  const calendar = createCalendar<TeamEvent>(body, {
    events: teamEvents(),
    view: 'month',
    date: at(17, 9),
    firstDay: 1,
    selectable: true,
    businessHours: { daysOfWeek: [1, 2, 3, 4, 5], startTime: '08:00', endTime: '18:00' },
    theme: docsTheme(),
  });

  const onView = () => calendar.setView(view.value as ViewType);
  view.addEventListener('change', onView);
  let shiftHeld = false;
  const trackShift = (event: KeyboardEvent) => {
    shiftHeld = event.shiftKey;
  };
  document.addEventListener('keydown', trackShift);
  document.addEventListener('keyup', trackShift);

  const time = (d: Date) =>
    d.toLocaleString('en-US', { weekday: 'short', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' });
  const offs = [
    calendar.on('eventClick', ({ event, occurrence }) => {
      status.textContent = `${event.title}, ${time(occurrence.start)}${event.location ? ` in ${event.location}` : ''}`;
    }),
    calendar.on('eventDrop', (change) => {
      if (change.isRecurring && shiftHeld) change.scope = 'all';
      status.textContent = `${change.event.title} moved to ${time(change.start)} (${change.isRecurring ? `scope: ${change.scope}` : 'single event'})`;
    }),
    calendar.on('eventResize', (change) => {
      status.textContent = `${change.event.title} now ends ${time(change.end)}`;
    }),
    calendar.on('viewChange', ({ view: next }) => {
      view.value = next;
    }),
  ];
  status.textContent = 'Click an event for details.';
  const stopTheme = onDocsThemeChange((theme) => calendar.update({ theme }));
  return () => {
    view.removeEventListener('change', onView);
    document.removeEventListener('keydown', trackShift);
    document.removeEventListener('keyup', trackShift);
    for (const off of offs) off();
    stopTheme();
    calendar.destroy();
  };
}
```

## What it does

- **Six views**: `'month'`, `'week'`, `'day'`, `'days'` (an N-day time grid), `'agenda'` and `'year'`, with a toolbar you can rearrange or turn off. See [Views](https://docs.birchui.com/calendar/views.md).
- **Recurring events** from RFC 5545 rules (`RRULE` with `BYDAY` ordinals, `BYMONTHDAY`, `BYSETPOS`, `COUNT`, `UNTIL`, `WKST`) plus `EXDATE` exceptions, expanded only for the visible range. See [Recurrence](https://docs.birchui.com/calendar/recurrence.md).
- **Time zones** through `Intl`, correct across daylight saving changes, including events that belong to a zone of their own. See [Time zones](https://docs.birchui.com/calendar/time-zones.md).
- **iCalendar import and export** with `parseICS` and `toICS`. See [iCalendar](https://docs.birchui.com/calendar/ical.md).
- **Editing** by drag, resize, select-to-create and keyboard, on mouse and touch, with validators and a read-only mode. See [Interactions](https://docs.birchui.com/calendar/interactions.md).
- **Async loading** of events per visible range, with cancellation of stale requests. See [Event sources](https://docs.birchui.com/calendar/event-sources.md).
- **Accessibility**: a WAI-ARIA grid month view, roving focus, full screen-reader labels and live announcements. See [Keyboard and accessibility](https://docs.birchui.com/calendar/accessibility.md).

## Install

```bash
npm install @birchui/calendar
```

The package depends on `@birchui/core` and `@birchui/license`, which npm installs for you. The stylesheet is injected the first time a calendar is created. To ship the CSS yourself, for example under a strict Content Security Policy, pass `injectStyles: false` and import it:

```ts
import '@birchui/calendar/styles.css';
```

## Create a calendar

`createCalendar(container, options)` renders into an element you own and returns the calendar API. Every option is optional; with none at all you get an empty month view for the current month.

```ts title="team-calendar.ts"
import { createCalendar } from '@birchui/calendar';

const calendar = createCalendar(document.getElementById('team-calendar')!, {
  view: 'month',
  date: '2026-12-01',
  timeZone: 'America/Chicago',
  locale: 'en-US',
  height: 640,
  businessHours: { daysOfWeek: [1, 2, 3, 4, 5], startTime: '08:00', endTime: '17:30' },
  events: [
    {
      id: 'standup',
      title: 'Support team stand-up',
      start: '2026-12-01T09:00',
      end: '2026-12-01T09:15',
      rrule: 'FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR',
      exdates: ['2026-12-25T09:00'],
    },
    {
      id: 'visit-3307',
      title: 'Site visit: Northgate Clinic',
      start: '2026-12-08T13:00',
      end: '2026-12-08T15:30',
      color: '#0f766e',
      location: '1450 Northgate Blvd',
    },
    {
      id: 'maintenance',
      title: 'Server maintenance window',
      start: '2026-12-08T22:00',
      end: '2026-12-09T02:00',
      rrule: 'FREQ=MONTHLY;BYDAY=2TU',
      color: '#b45309',
    },
    { id: 'holiday-xmas', title: 'Office closed: Christmas Day', start: '2026-12-25', allDay: true },
  ],
});

calendar.on('eventClick', ({ event, occurrence }) => {
  openEventPanel(event.id, occurrence.start);
});
```

A few rules worth knowing up front:

- Strings without an offset, such as `'2026-12-08T13:00'`, are wall-clock times in the calendar's `timeZone`. Date-only strings, such as `'2026-12-25'`, are all-day. `end` is exclusive.
- `height` defaults to `'auto'`, which lets the calendar grow to fit its content. Pass a number of pixels for a fixed height with scrolling inside.
- Extra fields on your events, such as `location` above, are kept and passed back to you in every payload. `location` is also read aloud by screen readers.

## The widget contract

`createCalendar` returns a `CalendarApi`, which includes the four members every Birch UI component shares:

| Member | What it does |
| --- | --- |
| `element` | The calendar's root element. |
| `update(partial)` | Applies only the options you pass, without recreating the calendar. |
| `on(event, listener)` | Subscribes to an event and returns an unsubscribe function. Payloads are always objects. |
| `destroy()` | Removes the DOM, cancels pending loads and releases every listener and timer. |

```ts
calendar.update({ view: 'week', timeZone: 'Europe/Berlin' });

const stop = calendar.on('rangeChange', ({ start, end, view }) => {
  console.info(`Showing ${view} from ${start.toISOString()} to ${end.toISOString()}`);
});

stop();
calendar.destroy();
```

On top of the contract the API has navigation (`setView`, `gotoDate`, `next`, `prev`, `today`), data (`setEvents`, `addEvent`, `updateEvent`, `removeEvent`, `getOccurrences`), recurrence editing (`updateOccurrence`, `removeOccurrence`) and loading (`refetch`, `isLoading`). The [API and events](https://docs.birchui.com/calendar/api.md) page lists everything.

## Activate your license

Set the key once for every Birch UI widget on the page, before the first calendar is created, or pass it per instance:

```ts
import { setLicenseKey } from '@birchui/license';

setLicenseKey(import.meta.env.VITE_BIRCHUI_LICENSE);
```

```ts
createCalendar(container, { ...options, licenseKey: 'LQ1.…' });
```

The calendar checks the key for the `calendar` product. Verification happens in the browser with no network call. A missing or invalid key never disables anything: it adds a small watermark to the calendar and logs one console warning, and on `localhost` the watermark is skipped. Changing `licenseKey` through `update()` re-checks it. See [Licensing and activation](https://docs.birchui.com/getting-started/licensing.md) for key format and seat rules.

## Use it in your framework

The framework adapters do not ship a ready-made calendar component, but each one exports the generic factory it uses for its own components. Pass it `calendarDefinition` and you get a component that creates the calendar on mount, sends changed props to `update()` and forwards every calendar event.

**JavaScript**

```ts
import { createCalendar } from '@birchui/calendar';

const calendar = createCalendar(document.getElementById('team-calendar')!, {
  view: 'month',
  events,
  height: 640,
});

calendar.on('eventDrop', ({ event, start, end }) => saveEvent(event.id, { start, end }));
```

**React**

```tsx
import { createReactComponent } from '@birchui/react';
import { calendarDefinition } from '@birchui/calendar';

export const BirchCalendar = createReactComponent(calendarDefinition);

export function TeamCalendar({ events }: { events: TeamEvent[] }) {
  return (
    <BirchCalendar
      view="month"
      events={events}
      height={640}
      onEventDrop={({ event, start, end }) => saveEvent(event.id, { start, end })}
    />
  );
}
```

**Vue**

```vue
<script setup lang="ts">
import { createVueComponent } from '@birchui/vue';
import { calendarDefinition, type CalendarEventMap } from '@birchui/calendar';

const BirchCalendar = createVueComponent(calendarDefinition);

defineProps<{ events: TeamEvent[] }>();

function onEventDrop({ event, start, end }: CalendarEventMap['eventDrop']) {
  saveEvent(event.id, { start, end });
}
</script>

<template>
  <BirchCalendar view="month" :events="events" :height="640" @event-drop="onEventDrop" />
</template>
```

**Angular**

```ts
import { ChangeDetectionStrategy, Component, input, output } from '@angular/core';
import { injectBirchWidget, withOverrides, type WidgetOutputs } from '@birchui/angular';
import {
  calendarDefinition,
  type CalendarApi,
  type CalendarEventMap,
  type CalendarOptions,
} from '@birchui/calendar';

@Component({
  selector: 'app-calendar',
  standalone: true,
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: '',
  styles: ':host { display: block; }',
})
export class CalendarComponent implements WidgetOutputs<CalendarEventMap> {
  readonly options = input<CalendarOptions>({});
  readonly events = input<CalendarOptions['events']>();

  readonly ready = output<CalendarEventMap['ready']>();
  readonly eventClick = output<CalendarEventMap['eventClick']>();
  readonly eventDoubleClick = output<CalendarEventMap['eventDoubleClick']>();
  readonly eventDrop = output<CalendarEventMap['eventDrop']>();
  readonly eventResize = output<CalendarEventMap['eventResize']>();
  readonly eventRemove = output<CalendarEventMap['eventRemove']>();
  readonly select = output<CalendarEventMap['select']>();
  readonly dateClick = output<CalendarEventMap['dateClick']>();
  readonly viewChange = output<CalendarEventMap['viewChange']>();
  readonly rangeChange = output<CalendarEventMap['rangeChange']>();
  readonly moreClick = output<CalendarEventMap['moreClick']>();
  readonly loading = output<CalendarEventMap['loading']>();

  private readonly widget = injectBirchWidget(calendarDefinition, this, () =>
    withOverrides<CalendarOptions>(this.options(), { events: this.events() }),
  );

  get api(): CalendarApi | undefined {
    return this.widget.instance;
  }
}
```

**Svelte**

```svelte
<script lang="ts">
  import { createSvelteAction } from '@birchui/svelte';
  import { calendarDefinition, type CalendarApi } from '@birchui/calendar';

  const birchCalendar = createSvelteAction(calendarDefinition);

  let { events }: { events: TeamEvent[] } = $props();
  let api: CalendarApi | null = $state.raw(null);
</script>

<div
  use:birchCalendar={{
    view: 'month',
    events,
    height: 640,
    on: { eventDrop: ({ event, start, end }) => saveEvent(event.id, { start, end }) },
    onReady: (calendar) => (api = calendar),
  }}
></div>
```

**Solid**

```tsx
import { createSolidComponent } from '@birchui/solid';
import { calendarDefinition } from '@birchui/calendar';

export const BirchCalendar = createSolidComponent(calendarDefinition);

export function TeamCalendar(props: { events: TeamEvent[] }) {
  return (
    <BirchCalendar
      view="month"
      events={props.events}
      height={640}
      onEventDrop={({ event, start, end }) => saveEvent(event.id, { start, end })}
    />
  );
}
```

**Web Component**

```html
<birchui-calendar id="team-calendar" view="month"></birchui-calendar>

<script type="module">
  import { createElementClass } from '@birchui/element';
  import { calendarDefinition } from '@birchui/calendar';

  customElements.define(
    'birchui-calendar',
    createElementClass(calendarDefinition, {
      optionKeys: ['events', 'eventSource', 'date', 'businessHours'],
      attributes: { view: 'string', 'time-zone': 'string', locale: 'string', height: 'number' },
      requiredOptions: [],
    }),
  );

  const calendar = document.getElementById('team-calendar');
  calendar.events = events;
  calendar.addEventListener('event-drop', ({ detail: { event, start, end } }) => {
    saveEvent(event.id, { start, end });
  });
</script>
```

Notes per adapter:

- **React and Solid**: options are props, events are `on…` props (`onEventDrop`, `onRangeChange`), and `ref` gives you the `CalendarApi`. Props are typed with the base `CalendarEvent` type.
- **Vue**: pass options as attributes (kebab-case is converted to camelCase) or as an `options` object. Events are kebab-case (`@event-drop`, `@range-change`). The component exposes `api`.
- **Angular**: `injectBirchWidget` needs one output per calendar event, which is why the wrapper declares all twelve. Read the instance from `api` after the first render.
- **Svelte**: `createSvelteAction` gives you an action. Its parameter is the options plus `on` (handlers keyed by event name) and `onReady` (called once with the API).
- **Web Component**: `createElementClass` turns any widget definition into a custom element. `optionKeys` become properties, `attributes` are observed and converted to camelCase options, and `requiredOptions: []` creates the calendar as soon as the element is connected. Events are kebab-case `CustomEvent`s with the payload in `detail`, and `element.api` is the `CalendarApi`. Define the element in the browser only; the class needs a DOM.

## Next steps

- [Views](https://docs.birchui.com/calendar/views.md): month, week, day, agenda and year, the toolbar and navigation.
- [Recurrence](https://docs.birchui.com/calendar/recurrence.md): repeating events and editing single occurrences.
- [Interactions](https://docs.birchui.com/calendar/interactions.md): drag, resize, select and validation.
- [Event sources](https://docs.birchui.com/calendar/event-sources.md): load events from your server per visible range.
