Skip to Content
Version 2.0 is out with React 19 support and an ESM build. Read the migration guide →
Custom rendering

Custom rendering

The calendar positions and sizes every item. What goes inside is up to you. There are two levels for regular items and two for the row of long items above the timeline.

PropReplacesArgumentsViews
renderItemThe whole item(item, isHovered)All
renderItemTextOnly the content of the default item(item)All
renderHeaderItemA whole item in the row above the timeline(item, extras)WEEK_TIME, DAY
renderHeaderItemTextOnly the content of such an item(item)WEEK_TIME, DAY

Toggle them below to compare with the defaults.

View
Loading calendar…

renderItem

Returns the element drawn for an item. The calendar still positions it, sizes it to the item’s duration in timeline views, and handles hover and onItemClick.

<Calendar renderItem={(item, isHovered) => ( <div className={isHovered ? 'event event--hovered' : 'event'}> <strong>{item.title}</strong> <span>{item.room}</span> </div> )} />

isHovered is true while the pointer is over any part of that item, including the other parts of an item that spans several days. It is always false when disableHoverEffect is set.

Fill the space you are given, for example with height: 100%, so that timeline items keep their size.

renderItemText

Keeps the default box, with its background, border and hover style, and replaces only the text inside. Use it to change the time format or to add details.

import { format } from 'date-fns'; <Calendar renderItemText={(item) => ( <> <div>{item.title}</div> <div> {format(new Date(item.startTime), 'HH:mm')}–{format(new Date(item.endTime), 'HH:mm')} </div> </> )} />;

When both are set, renderItem wins and renderItemText is not used.

renderHeaderItem

In WEEK_TIME and DAY, items longer than 24 hours are drawn in a row above the timeline. renderHeaderItem replaces those items. Its second argument tells you where the item sits:

interface HeaderItemExtras { gridColumn: string; // the CSS grid columns the item covers, e.g. '2 / 5' isFromPrevious?: boolean; // it started before the first visible day isFromNext?: boolean; // it continues after the last visible day }
<Calendar renderHeaderItem={(item, { isFromPrevious, isFromNext }) => ( <button className="all-day" onClick={() => openEditor(item.id)}> {isFromPrevious && '← '} {item.title} {isFromNext && ' →'} </button> )} />

A custom header item does not call onItemClick on its own. Add your own click handler, as in the example above.

renderHeaderItemText

Keeps the default header item, with its arrows for items continuing from or to another week, and replaces only its text.

<Calendar renderHeaderItemText={(item) => <span>🗓 {item.title}</span>} />
Last updated on