This is the full developer documentation for weekwise # A calendar that works with your dates, not its own. > Day, week and month views with drag, resize and click-to-create. Plug in date-fns, Day.js, Luxon or Temporal, in any time zone. ↔ ### Drag, resize, create Move events between days, stretch them across midnight, or draw a new one on the timeline. fn ### Any date library Adapters for date-fns, Day.js, Luxon and Temporal. The calendar never reads a date on its own. TZ ### Time zones built in Show the calendar in any IANA zone: days start at its midnight, wherever the user is. ▦ ### Day, week, month Month rows fit as many lanes as they can and collapse the rest into “+N more”. {} ### Theme with CSS variables Colors, radius and the time column come from `--ww-*` variables, in a cascade layer your CSS overrides. TS ### Typed end to end Generic over your event type and your date type. SSR and the Next.js App Router work. ## Same calendar, with or without React [Section titled “Same calendar, with or without React”](#same-calendar-with-or-without-react) The layout logic lives in `@weekwise/core`. The React and DOM packages render it the same way and share one theme of CSS variables. * React ```tsx import Calendar, { DateLocalizationProvider } from "@weekwise/react"; import { DateFnsAdapter } from "@weekwise/adapter-date-fns"; import "@weekwise/react/styles.css"; e.id} eventTimeFrameResolver={(e) => ({ start: e.start, end: e.end })} onEventChange={move} > {(event) =>
{event.title}
}
``` * Vanilla DOM ```ts import { createCalendar } from "@weekwise/dom"; import { DateFnsAdapter } from "@weekwise/adapter-date-fns"; import "@weekwise/dom/styles.css"; const calendar = createCalendar(element, { adapter: new DateFnsAdapter(), items: events, eventKeyResolver: (e) => e.id, eventTimeFrameResolver: (e) => ({ start: e.start, end: e.end }), renderEvent: (e) => e.title, onEventChange: move, }); ``` date-fns Day.js Luxon Temporal # Introduction > What weekwise is, and which packages to install. weekwise is a day, week and month calendar with drag-and-drop event management, for React or plain DOM. * **Three views**: day and week on a timeline, month as a grid; a toolbar to navigate and switch views, and a date picker popover. * **Direct manipulation**: drag events to another day or time, resize them by their edges (into other days too), draw new events on the timeline, stretch multi-day events in the month view. * **Your data stays yours**: the calendar never changes the events; it reports what the user did. * **Any date library, any date type**: the UI talks to dates only through an [adapter](/guides/date-adapters/). * **Time zones**: with the Temporal or Luxon adapter the calendar shows any IANA time zone. * **Localized by one setting**: the adapter’s locale sets formats, names, the first day of the week and the interface language. * **Themeable** with CSS variables; styles live in a cascade layer, so your CSS always wins. ## Packages [Section titled “Packages”](#packages) | Package | | | ---------------------------- | ------------------------------------------------------------------------------------ | | `@weekwise/react` | React calendar component. | | `@weekwise/dom` | The same calendar without a framework, rendered with plain DOM. | | `@weekwise/adapter-date-fns` | `DateAdapter` backed by date-fns. | | `@weekwise/adapter-dayjs` | `DateAdapter` backed by Day.js. | | `@weekwise/adapter-luxon` | `DateAdapter` backed by Luxon, with a time zone option. | | `@weekwise/adapter-temporal` | `DateAdapter` of `Temporal.ZonedDateTime`, in any time zone. No dependencies. | | `@weekwise/core` | The `DateAdapter` contract, types and event layout. You rarely install it yourself. | | `@weekwise/dnd` | Store over native HTML drag and drop or pointer events. Independent of the calendar. | You need one UI package and one adapter: * [Quick start with React](/getting-started/react/) * [Quick start with vanilla DOM](/getting-started/dom/) ## With an AI assistant [Section titled “With an AI assistant”](#with-an-ai-assistant) These docs are also published as plain text for language models, following [llms.txt](https://llmstxt.org/): * [`/llms.txt`](/llms.txt): an overview with links to the rest. * [`/llms-full.txt`](/llms-full.txt): the whole documentation in one file. * [`/llms-small.txt`](/llms-small.txt): a shorter version, without the examples. Give one of them to your coding assistant so it writes code against the current API. # Quick start with vanilla DOM > The same calendar without a framework. `@weekwise/dom` renders the calendar with plain DOM: no framework, and no date library of its own. ## 1. Install [Section titled “1. Install”](#1-install) ```sh npm install @weekwise/dom @weekwise/adapter-date-fns date-fns ``` ## 2. Create the calendar [Section titled “2. Create the calendar”](#2-create-the-calendar) ```ts 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(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](/reference/dom/) for every option and the instance API. # Quick start with React > Render a week view with a few events, then let people drag them around. Render a week view with a few events, then let people drag them around. ## 1. Install [Section titled “1. Install”](#1-install) The calendar needs a date adapter. This guide uses date-fns; [the others](/guides/date-adapters/) work the same way. * npm ```sh npm install @weekwise/react @weekwise/adapter-date-fns date-fns ``` * pnpm ```sh pnpm add @weekwise/react @weekwise/adapter-date-fns date-fns ``` * yarn ```sh yarn add @weekwise/react @weekwise/adapter-date-fns date-fns ``` ## 2. Render the calendar [Section titled “2. Render the calendar”](#2-render-the-calendar) Wrap the calendar in a `DateLocalizationProvider` with an adapter. Then tell the calendar how to read your events: a key and a start–end pair. The children render one event card. ```tsx import { useState } from "react"; import Calendar, { DateLocalizationProvider } from "@weekwise/react"; import { DateFnsAdapter } from "@weekwise/adapter-date-fns"; import "@weekwise/react/styles.css"; type Event = { id: string; title: string; start: Date; end: Date }; export function Schedule({ initial }: { initial: Event[] }) { const [events, setEvents] = useState(initial); return ( event.id} eventTimeFrameResolver={(event) => ({ start: event.start, end: event.end })} onEventChange={(event, start, end) => setEvents((prev) => prev.map((e) => (e.id === event.id ? { ...e, start, end } : e))) } onEventCreate={(start, end) => setEvents((prev) => [...prev, { id: crypto.randomUUID(), title: "New event", start, end }]) } > {(event) =>
{event.title}
}
); } ``` Tip The calendar never changes your data. `onEventChange` tells you where the event went; you decide whether to keep it. If you don’t apply the change, the event snaps back. `adapter` accepts either a class (`DateFnsAdapter`) or a ready instance (`new DateFnsAdapter({ locale: fr })`). Create the instance outside the component, or memoize it, so the context value stays stable. ## Next steps [Section titled “Next steps”](#next-steps) * [Rendering events](/guides/rendering-events/): style the cards, flatten the edges of multi-day events. * [Interactions](/guides/interactions/): what each gesture does and how to limit it. * [`@weekwise/react` reference](/reference/react/): every prop, and Next.js notes. # Date adapters > The calendar talks to dates only through an adapter. Pick one, or write your own. The calendar never formats, computes or even reads dates itself: an adapter does. Its date type is the one the calendar takes and gives: `Date` with the date-fns, Day.js and Luxon adapters, `Temporal.ZonedDateTime` with the Temporal one. | Adapter | Date type | Time zone | Peer dependency | | ---------------------------- | ------------------------ | ------------- | --------------- | | `@weekwise/adapter-date-fns` | `Date` | the browser’s | `date-fns` | | `@weekwise/adapter-dayjs` | `Date` | the browser’s | `dayjs` | | `@weekwise/adapter-luxon` | `Date` | any IANA zone | `luxon` 3.4+ | | `@weekwise/adapter-temporal` | `Temporal.ZonedDateTime` | any IANA zone | none | * date-fns ```ts import { DateFnsAdapter } from "@weekwise/adapter-date-fns"; import { fr } from "date-fns/locale/fr"; const adapter = new DateFnsAdapter({ locale: fr }); ``` * Day.js ```ts import { DayjsAdapter } from "@weekwise/adapter-dayjs"; import fr from "dayjs/locale/fr"; const adapter = new DayjsAdapter({ locale: fr }); ``` * Luxon ```ts import { LuxonAdapter } from "@weekwise/adapter-luxon"; const adapter = new LuxonAdapter({ locale: "fr", timeZone: "Europe/Paris" }); ``` * Temporal ```ts import { TemporalAdapter } from "@weekwise/adapter-temporal"; const adapter = new TemporalAdapter({ locale: "fr", timeZone: "Europe/Paris" }); ``` Give the adapter to the UI package: `` in React, `createCalendar(element, { adapter })` in the DOM package. ## Formats [Section titled “Formats”](#formats) Every adapter has built-in patterns you can override in its own tokens: ```ts new DateFnsAdapter({ locale: zhCN, formats: { timeShort: "HH:mm", weekdayShort: "EEEEEE" } }); ``` | Pattern | Used for | | ---------------------------------------------- | ----------------------------------------- | | `timeShort` | Hour labels, now line, drag preview | | `date` | Drag preview | | `weekdayShort` | Column headers, date picker | | `dateTime`, `dateTimeShort`, `dateTimeLong`, … | Your own `format(date, "dateTime")` calls | Temporal has no format strings, so its patterns are either `Intl.DateTimeFormat` options or tokens (`dd.MM.yyyy`). ## Your own adapter [Section titled “Your own adapter”](#your-own-adapter) Any object implementing `DateAdapter` from `@weekwise/core` works. The calendar takes and gives dates of that type and never looks inside them. ```ts import type { DateAdapter } from "@weekwise/core"; export class MyAdapter implements DateAdapter { readonly locale = "en-GB"; // BCP 47 code: interface language and heading formats readonly weekStartsOn = 1; // default first day of the week readonly timeZone = "Europe/Berlin"; // optional IANA zone; omit for the runtime's zone toMillis(date: MyDate | number | string) { /* epoch ms: keys, sorting, timers */ } fromMillis(millis: number): MyDate { /* the date at epoch ms */ } // implement every other method of the interface } ``` Methods take `TDate | number | string` (a timestamp or an ISO string) and return `TDate`. Wall-clock methods (`getHours`, `getStartOfDay`, `addDays`…) work in the adapter’s time zone. `@weekwise/adapter-date-fns` is a reference implementation for `Date`, `@weekwise/adapter-temporal` for another date type and time zones. # Interactions > What each gesture does, and how to limit editing. The calendar is controlled: moving, resizing or creating an event does not change `items`. It calls a callback and waits for new `items`; if you don’t apply the change, the event snaps back. This is the place for validation, server calls and undo. | Gesture | Result | | ----------------------------------------- | ------------------------------------------------------------------------------------------- | | Drag on an empty part of a day | `onEventCreate(start, end)` | | Drag an event | `onEventChange(item, start, end)`: new day and/or time; the timeline scrolls near its edges | | Drag the top or bottom edge (day, week) | `onEventChange`: new start or end, into other days too | | Drag the left or right edge (month) | `onEventChange`: the event covers more or fewer days | | Double-click an empty month day | `onEventCreate`: one hour, starting now | | Double-click an event, or `Enter` on it | `onEventEdit(item)` (DOM package) | | `Delete` / `Backspace` on a focused event | `onEventDelete(item)` (DOM package) | | `Esc` during a drag | cancels it | ## Limiting edits [Section titled “Limiting edits”](#limiting-edits) Edits snap to `timeStep` minutes (15 by default). * `timeFrame: { hourMin, hourMax }` limits the visible hours and keeps edits inside them; `hideMinMaxTime` hides the hours outside. * `getIsDayDisabled(date)` blocks creating and dropping on a day. * `disabled` turns every interaction off. ```tsx date.getDay() === 0 || date.getDay() === 6} {...rest} /> ``` # Localization > The adapter's locale localizes names, formats, the first day of the week and the interface. One setting localizes everything: the adapter’s locale. It drives month and weekday names, date and time formats, the first day of the week and the interface text. ```tsx import { ru } from "date-fns/locale/ru"; ``` The visible words (“Today”, “Day”, “Week”, “Month”) come from the browser’s `Intl` data, so every locale gets them. The screen-reader labels of the navigation buttons, the view list and the buttons to hidden events, and the “+3 more” label have built-in translations for English, Russian, Ukrainian, German, French, Spanish, Portuguese, Italian, Dutch, Polish, Turkish, Chinese, Japanese and Korean. Switching the adapter re-renders the calendar in the new language and keeps the visible period. ## Changing single strings [Section titled “Changing single strings”](#changing-single-strings) ```tsx `+${count} mais`, earlier: (count) => `Eventos anteriores: ${count}`, later: (count) => `Eventos posteriores: ${count}`, }}> ``` In the DOM package pass `messages` as an option: `calendar.update({ messages: { today: "Now" } })`. `useMessages()` returns the resolved strings for your own React components. The first day of the week comes from the locale; override it with `startWeek` (`0` is Sunday). # Rendering events > The calendar positions events; their content is yours. `items` is an array of anything. Two resolvers tell the calendar how to read it: * `eventKeyResolver(item)` returns a unique, stable key; * `eventTimeFrameResolver(item)` returns `{ start, end }` in the adapter’s date type. You render the content of each event yourself; the calendar positions it. ## React [Section titled “React”](#react) `children` is a function of the item, the view and the part of the event being drawn: ```tsx {(event, view, part) => view === "month" ? ( {event.title} ) : (
{event.title}
) }
``` An event across midnight is drawn in every day it covers. `part.isStart` is `false` on the parts that continue from the previous day, `part.isEnd` on those that continue into the next one. The same parts carry `data-continues-before` / `data-continues-after` attributes, for CSS. ### Short events [Section titled “Short events”](#short-events) An event of 15 minutes is 15px high, and 11px in a compact calendar. A day/week event is a size container named `ww-event`: fit its content to the height with a container query. ```css @container ww-event (max-height: 25px) { .my-event { display: flex; align-items: center; padding-block: 0; line-height: 1; } .my-event__time { display: none; } } ``` ## DOM [Section titled “DOM”](#dom) `renderEvent(item, view)` returns a string (inserted as text, never as HTML) or any DOM node. `eventClassName(item)` adds classes to an event, and since theme variables cascade, a class can recolor a single event: ```ts createCalendar(element, { /* … */ eventClassName: (event) => `event--${event.category}` }); ``` ```css .event--meeting { --ww-event-bg: #e3f5f1; --ww-event-border: #c9eae2; --ww-event-text: #115e59; } ``` Parts that continue into another day get `.ww-event--continued-before` / `.ww-event--continued-after`. An event is a size container named `ww-event` too. A short one drops the padding around its content and centres it; your own content can follow its height with `@container ww-event (...)`. # Theming > Restyle the calendar with CSS variables, per-event classes or your own rules. Import the package stylesheet, then adjust it at the level you need. Both UI packages use the same variables. ## 1. Theme variables [Section titled “1. Theme variables”](#1-theme-variables) Set them on the container or `:root`: ```css #calendar { --ww-accent: #7c3aed; /* today, focus rings, picker */ --ww-event-bg: #ede9fe; --ww-event-border: #ddd6fe; --ww-event-text: #4c1d95; /* also the dot of month-view events */ --ww-now: #f97316; /* "now" line */ --ww-surface: #fff; /* around the card; match your page */ } ``` The date picker popover and drag previews, which render in `document.body`, pick the variables up from the calendar automatically. [All variables](/reference/css-variables/). ## 2. Per event [Section titled “2. Per event”](#2-per-event) The content is yours to render (see [Rendering events](/guides/rendering-events/)); in the DOM package `eventClassName` adds classes that can set the variables for one event. ## 3. Your own rules [Section titled “3. Your own rules”](#3-your-own-rules) Every element of the DOM package has a stable `ww-` class (`.ww-event`, `.ww-month__day`, `.ww-toolbar__view--active`) and state attributes (`[data-today]`, `[data-outside]`, `[data-disabled]`, `[data-past]`). The built-in styles live in the `weekwise` [cascade layer](https://developer.mozilla.org/docs/Web/CSS/@layer), so any of your own CSS overrides them regardless of specificity: ```css .ww-event { border-radius: 8px; font-weight: 600; } ``` If your site puts its own styles in cascade layers too (a CSS reset, a framework such as Starlight or Tailwind), declare the order before any stylesheet, so the calendar’s layer comes after the reset: ```html ``` ## Small containers [Section titled “Small containers”](#small-containers) The calendar adapts to the width of its container, not of the window, so it fits a widget or a side panel as well as a phone: | Width | Layout | | ----------- | -------------------------------------------------------------------------------- | | over 900px | Regular | | 521–900px | Compact: a lower toolbar and day header, 44px hours, no lines between time steps | | up to 520px | Narrow: also 40px hours, and the view tabs become a list | In a scrollable timeline, buttons at the top and bottom of each day point to the events out of view and scroll to them. The React calendar marks the layout with `data-ww-size="compact"` or `"narrow"` on its root, the DOM one with the `ww-calendar--compact` and `ww-calendar--narrow` classes; an explicit `rowHeight` (DOM package) keeps its hour height at every size. # Time zones > Show the calendar in any IANA time zone with the Luxon or Temporal adapter. With the Luxon or Temporal adapter the calendar shows any IANA time zone: days start at its midnight and times are its wall-clock times, wherever the user is. ## Luxon: `Date`s in another zone [Section titled “Luxon: Dates in another zone”](#luxon-dates-in-another-zone) Dates stay `Date`s, that is moments in time. Only how they are laid out changes. ```ts new LuxonAdapter({ locale: "en-US", timeZone: "America/New_York" }); ``` ## Temporal: `ZonedDateTime`s [Section titled “Temporal: ZonedDateTimes”](#temporal-zoneddatetimes) With `@weekwise/adapter-temporal` the calendar takes and gives `Temporal.ZonedDateTime`s: `viewValue`, `eventTimeFrameResolver`, `onEventChange` and the other date props use it. ```tsx import { TemporalAdapter } from "@weekwise/adapter-temporal"; const adapter = new TemporalAdapter({ locale: "en-US", timeZone: "America/New_York" }); ({ start: m.start, end: m.end })} onEventChange={(m, start, end) => save(m.id, start, end)} // ZonedDateTime in New York > {(m) => m.title} ``` Dates you give the calendar may be in any zone: a meeting at 09:00 in Berlin shows at 03:00 in New York. Switching the adapter to another zone keeps the day the user sees. A day stays 24 wall-clock hours long on daylight saving days. The adapter uses the global `Temporal`. Where the runtime has none, load a polyfill first, e.g. `import "temporal-polyfill/global"`. For TypeScript, add `"ESNext.Temporal"` to `lib` (TypeScript 6+) or use the polyfill’s global types. `withTimeZone(zone)` and `withLocale(locale)` return a copy with the other settings kept. `from(value)` reads an `Instant`, `PlainDateTime`, `PlainDate`, `Date` or epoch nanoseconds as a `ZonedDateTime` in the adapter’s zone. # CSS variables > Every theme variable of the calendar and its default. Both UI packages read the same variables. Set them on the calendar’s container or on `:root`. | Variable | Default | Used for | | --------------------- | ------------------------- | ------------------------------------------------------------------------------- | | `--ww-accent` | `#4f46e5` | Today, focus rings, the active date in the picker | | `--ww-accent-soft` | `#eef0ff` | Hover and drop-target tint | | `--ww-now` | `#d93d42` | Current time line | | `--ww-border` | `#ededeb` | Grid lines | | `--ww-border-soft` | `#f2f2f0` | Time-step lines inside an hour | | `--ww-control-border` | `#e4e4e1` | Outline of toolbar controls | | `--ww-muted` | `#63636b` | Secondary text | | `--ww-text` | `#18181b` | Text, the active view tab | | `--ww-bg` | `#fff` | The calendar card | | `--ww-surface` | `#f4f4f2` | Around the card, behind the toolbar | | `--ww-bg-muted` | `#fafaf8` | Days outside the month | | `--ww-bg-blocked` | `#fafaf8` | Past and disabled time | | `--ww-today-bg` | `#fafaff` | Today’s column | | `--ww-event-bg` | `#eef0ff` | Event background (DOM package) | | `--ww-event-border` | `#dadffb` | Event border (DOM package) | | `--ww-event-text` | `#3730a3` | Event text (DOM package) | | `--ww-event-dot` | `--ww-event-text` | The dot of month-view events (DOM package) | | `--ww-spotlight` | `rgba(79, 70, 229, 0.08)` | Highlight under a dragged event | | `--ww-preview-bg` | `#18181b` | Drag, resize and create time label | | `--ww-preview-text` | `#fff` | Its text | | `--ww-time-column` | `64px` | Width of the hour column (`44px` in a compact calendar, `40px` in a narrow one) | | `--ww-radius` | `18px` | Corner radius of the card (`14px` in a compact calendar) | The hour column is wide enough for 12-hour locales; it grows by itself when a label does not fit. # @weekwise/dom > Options and instance API of the framework-free calendar. ```ts import { createCalendar } from "@weekwise/dom"; import "@weekwise/dom/styles.css"; const calendar = createCalendar(element, options); ``` ## Options [Section titled “Options”](#options) | Option | Type | Description | | ------------------------ | ---------------------------------------- | -------------------------------------------------------------------------------------------------- | | `adapter` | `DateAdapter` | **Required.** Date adapter, e.g. `new DateFnsAdapter()`. | | `items` | `TValue[]` | Event data. | | `eventTimeFrameResolver` | `(item) => { start: Date; end: Date }` | Resolves an item to its time span. | | `eventKeyResolver` | `(item) => string \| number` | Resolves an item to a unique key. | | `renderEvent` | `(item, view) => string \| Node` | Event content. Strings are inserted as text, never as HTML. | | `eventClassName` | `(item) => string \| undefined` | Extra classes for an event element. | | `view` | `"day" \| "week" \| "month"` | Current view (defaults to `"week"`). | | `viewValue` | `Date` | Visible date (defaults to today). | | `startWeek` | `0 \| 1 \| … \| 6` | First day of the week (defaults to the adapter’s locale). | | `messages` | `Partial` | Interface strings over the built-in translation (see Localization). | | `timeStep` | `number` | Minutes per timeline step (defaults to `15`). | | `timeFrame` | `{ hourMin?: number; hourMax?: number }` | Visible hour range. When set, edits stay inside it and cannot go into the past. | | `hideMinMaxTime` | `boolean` | Hides hours outside `timeFrame`. | | `rowHeight` | `number` | Height of one hour in pixels (defaults to `60`, `44` in a compact calendar, `40` in a narrow one). | | `scrollable` | `boolean` | Scrolls the timeline inside the calendar. | | `disabled` | `boolean` | Disables all interactions. | | `getIsDayDisabled` | `(date) => boolean` | Disables creating and dropping events on a day. | | `pointerPreviewFormat` | `(from, to) => string` | Label shown next to the pointer while dragging. | | `onEventChange` | `(item, start, end) => void` | An event was moved or resized. | | `onEventCreate` | `(start, end) => void` | A new event was drawn. | | `onEventEdit` | `(item) => void` | An event was double-clicked or Enter was pressed on it. | | `onEventDelete` | `(item) => void` | Delete was pressed on an event. | | `onChangeView` | `(view) => void` | The user switched the view. | | `onChangeViewValue` | `(date, view) => void` | The user navigated to another date. | ## Instance [Section titled “Instance”](#instance) | Member | Description | | ------------------------------------- | ----------------------------------------------------------------------------------------------------- | | `update(options)` | Merges new options and re-renders. Setting `view` or `viewValue` here does not fire change callbacks. | | `setView(view)`, `setViewValue(date)` | Change the view or date, like the user would (callbacks fire). | | `next()`, `prev()`, `today()` | Navigate. | | `view`, `viewValue` | Current state. | | `element` | The calendar’s root element. | | `destroy()` | Removes the calendar, its listeners, timers and popovers. | ## Interactions [Section titled “Interactions”](#interactions) | Gesture | Result | | ----------------------------------------- | ---------------------------------------- | | Drag on an empty part of a day | `onEventCreate` | | Drag an event | `onEventChange` (new day and/or time) | | Drag the top or bottom edge of an event | `onEventChange` (new start or end) | | Double-click an empty month day | `onEventCreate` (one hour, starting now) | | Double-click an event, or `Enter` on it | `onEventEdit` | | `Delete` / `Backspace` on a focused event | `onEventDelete` | | `Esc` during a drag | cancels it | # @weekwise/react > Every prop of the React calendar, and Next.js notes. ```tsx import Calendar, { DateLocalizationProvider, useDateUtils, useMessages } from "@weekwise/react"; import "@weekwise/react/styles.css"; ``` ## Props [Section titled “Props”](#props) | Prop | Type | Description | | ------------------------ | ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | | `view` | `"day" \| "week" \| "month"` | Controlled current view. | | `defaultView` | `"day" \| "week" \| "month"` | Initial view (defaults to `"week"`). | | `viewValue` | `Date` | Controlled visible date. | | `defaultViewValue` | `Date` | Initial visible date (defaults to today). | | `startWeek` | `0 \| 1 \| ... \| 6` | First day of the week (defaults to the adapter’s locale). | | `timeStep` | `number` | Minutes per timeline step (defaults to `15`). | | `timeFrame` | `{ hourMin?: number; hourMax?: number }` | Visible hour range. When set, changes are constrained to the range. | | `hideMinMaxTime` | `boolean` | Hides time outside the `timeFrame`. | | `items` | `TValue[]` | Event data. | | `eventTimeFrameResolver` | `(item) => { start: Date; end: Date }` | Resolves an item to its time span. | | `eventKeyResolver` | `(item) => string \| number` | Resolves an item to a unique key. | | `disabled` | `boolean` | Disables interactions. | | `scrollable` | `boolean` | Makes the timeline scrollable. | | `getIsDayDisabled` | `(date: Date) => boolean` | Disables a day for event creation/drop. | | `onEventChange` | `(item, start, end) => void` | Called when an event is moved or resized. | | `onEventCreate` | `(start, end) => void` | Called when a new event is created on the timeline. | | `onEventDelete` | `(item) => void` | Called when an event is deleted. | | `onEventEdit` | `(item) => void` | Called when an event is edited. | | `onChangeView` | `(view) => void` | Called when the view changes. | | `onChangeViewValue` | `(viewValue, currentView) => void` | Called when the visible date changes. | | `pointerPreviewFormat` | `(from, to) => ReactNode` | Customizes the drag/resize preview label. | | `children` | `(item, view, part) => ReactNode` | Renders an event item. `part` (`{ isStart, isEnd }`) says whether the card continues from / into another day, to flatten its edges there. | Any other props are spread onto the root `div`. ## Next.js [Section titled “Next.js”](#nextjs) Works with the App Router (tested with Next.js 16 and React 19, including static prerendering). The package ships with a `"use client"` directive. Render the calendar from a **Client Component**: its `children` is a render function and the `adapter` is a class, and neither can be passed from a Server Component. app/schedule/Schedule.tsx ```tsx "use client"; import Calendar, { DateLocalizationProvider } from "@weekwise/react"; import { DateFnsAdapter } from "@weekwise/adapter-date-fns"; export default function Schedule() { return ( {(event) =>
{event.title}
}
); } ``` ```tsx // app/schedule/page.tsx (a Server Component) import Schedule from "./Schedule"; import "@weekwise/react/styles.css"; export default function Page() { return ; } ``` The calendar renders on the server and hydrates without mismatches: browser-only parts (drag and drop, popovers, the “now” line) appear after hydration. Note that a statically prerendered page is rendered at build time, when “today” may be a different day than when it is viewed. If you show the current week without a fixed `viewValue`, render the page dynamically (`export const dynamic = "force-dynamic"`) so the server and the browser agree on the date. ## Custom date library [Section titled “Custom date library”](#custom-date-library) Any object implementing the `DateAdapter` interface from `@weekwise/core` works as an adapter. Adapters for date-fns, Day.js, Luxon and Temporal are ready; see [`@weekwise/core`](/guides/date-adapters/#your-own-adapter) to write your own. The calendar’s date type follows the adapter: with `@weekwise/adapter-temporal`, `viewValue`, `eventTimeFrameResolver`, `onEventChange` and the other date props are `Temporal.ZonedDateTime`s. TypeScript infers it from the props; give it explicitly when it cannot: ` …>`. Read the adapter in your own components with `useDateUtils()`. # Month view > Multi-day bars, lanes that fit the row, and “+N more”. In the month view an event across several days is one bar. Each week row fits as many lanes as its height allows and collapses the rest into “+N more”. Drag a bar to move it, drag its left or right edge to change the days it covers, double-click an empty day to add an event. ```tsx {(event, view) => (view === "month" ? {event.title} : )} ``` # Another time zone > The same events, laid out in New York, Tokyo or Sydney. The Luxon adapter with a `timeZone` lays the same moments out in another zone’s wall-clock time. ```tsx const adapter = useMemo(() => new LuxonAdapter({ locale: "en-GB", timeZone }), [timeZone]); ``` For `Temporal.ZonedDateTime`s use the Temporal adapter: see [Time zones](/guides/time-zones/). # Without a framework > The DOM package with per-event colors. `@weekwise/dom` with `eventClassName` coloring events by category. Focus an event and press `Delete` to remove it. ```ts createCalendar(element, { // … eventClassName: (event) => `event--${event.color}`, onEventDelete(event) { events = events.filter((e) => e.id !== event.id); calendar.update({ items: events }); }, }); ``` # Week planner > An editable week with events across midnight. Drag events between days, stretch them by their edges, or draw a new one on an empty slot. “Release night” runs past midnight, so it is drawn in both days, with flat dashed edges where it continues. The event cards come from the render function: see [Rendering events](/guides/rendering-events/). # Working hours > Only 08:00–18:00 on weekdays. `timeFrame` hides the night and keeps edits inside the working day; `getIsDayDisabled` blocks weekends. ```tsx date.getDay() === 0 || date.getDay() === 6} {...props} /> ```