Rendering events
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.
children is a function of the item, the view and the part of the event being drawn:
<Calendar {...props}> {(event, view, part) => view === "month" ? ( <span>{event.title}</span> ) : ( <div className="card" style={{ // flat where the event continues from or into another day borderTopLeftRadius: part.isStart ? 8 : 0, borderTopRightRadius: part.isStart ? 8 : 0, borderBottomLeftRadius: part.isEnd ? 8 : 0, borderBottomRightRadius: part.isEnd ? 8 : 0, }} > {event.title} </div> ) }</Calendar>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”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.
@container ww-event (max-height: 25px) { .my-event { display: flex; align-items: center; padding-block: 0; line-height: 1; } .my-event__time { display: none; }}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:
createCalendar(element, { /* … */ eventClassName: (event) => `event--${event.category}` });.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 (...).