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

Collapsing cells

A busy day can push the rest of the month out of sight. cellDisplayMode collapses cells so that each shows only its last item.

View
state
Loading calendar…

Shape

cellDisplayMode has an entry per view. Each entry has a state and a list of inactiveCells:

<Calendar cellDisplayMode={{ MONTH: { state: 'CUSTOM', inactiveCells: ['2025-06-03', '2025-06-10'], }, WEEK_IN_PLACE: { state: 'ALL_COLLAPSED', inactiveCells: [], }, }} />
stateEffect
ALL_EXPANDEDEvery cell shows all its items. This is the default.
ALL_COLLAPSEDEvery cell shows only its last item.
CUSTOMCells listed in inactiveCells are collapsed, the others are expanded.

It applies to MONTH, WEEK, WEEK_IN_PLACE and DAY_IN_PLACE. The timeline views size items by time instead, so they have nothing to collapse.

Cell keys

The entries of inactiveCells identify cells by their local date and time:

ViewKey formatExample
MONTH, WEEKyyyy-MM-dd2025-06-03
WEEK_IN_PLACE, DAY_IN_PLACEyyyy-MM-dd HH:mm:ss2025-06-03 14:00:00

You rarely build these by hand. onCellClick gives you the key of the clicked cell as timeDate, so toggling a cell is short:

const [inactiveCells, setInactiveCells] = useState([]); <Calendar currentView="MONTH" cellDisplayMode={{ MONTH: { state: 'CUSTOM', inactiveCells } }} onCellClick={({ timeDate }) => setInactiveCells((cells) => cells.includes(timeDate) ? cells.filter((cell) => cell !== timeDate) : [...cells, timeDate], ) } />;

In MONTH, an item that spans several days is hidden from the later days of its run once one of its days is collapsed, so a collapsed day does not leave a broken bar behind.

TypeScript

The package types state as an enum it does not export, so a plain 'CUSTOM' string does not type-check. Derive the type from the props instead; see TypeScript.

Last updated on