Quick start with vanilla DOM
@weekwise/dom renders the calendar with plain DOM: no framework, and no date library of its own.
1. Install
Section titled “1. Install”npm install @weekwise/dom @weekwise/adapter-date-fns date-fns2. Create the calendar
Section titled “2. Create the calendar”import { createCalendar } from "@weekwise/dom";import { DateFnsAdapter } from "@weekwise/adapter-date-fns";import "@weekwise/dom/styles.css";
type Event = { id: string; title: string; start: Date; end: Date };
let events: Event[] = [];
const calendar = createCalendar<Event>(document.getElementById("calendar")!, { adapter: new DateFnsAdapter(), items: events, scrollable: true, eventKeyResolver: (event) => event.id, eventTimeFrameResolver: (event) => ({ start: event.start, end: event.end }), renderEvent: (event) => event.title, onEventChange(event, start, end) { events = events.map((e) => (e.id === event.id ? { ...e, start, end } : e)); calendar.update({ items: events }); }, onEventCreate(start, end) { events = [...events, { id: crypto.randomUUID(), title: "New event", start, end }]; calendar.update({ items: events }); },});The calendar fills its container, so give the container a height (or set scrollable: true to
scroll the timeline inside it).
Callbacks tell you what the user did, and you pass the new items back with update(). If you
ignore a change, the event snaps back. destroy() removes the calendar with its listeners, timers
and popovers.
See the @weekwise/dom reference for every option and the instance API.