Examples › Expanding rows
The rowExpansion property lets you display additional content below a row when the user clicks on it — the so-called “row expansion” behavior.
Basic usage
In its most basic form, the feature only requires a content function returning the content to be lazily rendered when a row is expanded. The function receives an object with the current record, its index and a collapse callback (more on that below).
Click on a row to test the behavior:
Specifying collapse properties
Internally, the expanded content is rendered inside a Mantine Collapse component. You can customize its animateOpacity, transitionDuration and transitionTimingFunction properties by passing a collapseProps object, like so:
Here is the code for the above example:
Allowing multiple rows to be expanded at once
By default, only one row can be expanded at a time; expanding a row collapses the previously expanded one. Set allowMultiple to true to change this behavior:
Here is the code for the above example:
Specifying which rows are expandable
Use the expandable function to specify which rows can be expanded. It receives an object with the current record and its index and should return a boolean:
Here is the code for the above example:
Specifying which rows are initially expanded
Use the initiallyExpanded function to specify which rows are expanded when the table is first rendered. Note that, unless allowMultiple is true, only the first matching row will be expanded:
Here is the code for the above example:
Always expand all rows
If you want all rows to be locked in their expanded state, set the row expansion trigger property to 'always':
Here is the code for the above example:
Using the collapse function in row expansion content
Besides the current record and its index, the content function also receives a collapse callback that you can call to collapse the expanded row — for instance, when the user saves or cancels the changes in an inline editor:
Here is the code for the above example:
Lazy-loading row expansion data
As mentioned above, the content function is lazily executed when a row is expanded to prevent creating unnecessary DOM elements.
If your row expansion content needs to show data that doesn’t come from the table records, you can take advantage of this behavior to load it only when a row is expanded:
Here is the code for the above example:
Controlled mode
To control which rows are expanded from outside the table, set the rowExpansion.expanded property to an object containing:
recordIds→ an array containing the IDs of the currently expanded records;onRecordIdsChange→ a callback function invoked with the new array of expanded record IDs when the user expands or collapses a row.
Here is the code for the above example:
Expanding rows with a toggle button
If you don’t want rows to expand or collapse when clicked, set the rowExpansion.trigger property to 'never' and control the expansion state yourself. For instance, here is how you could expand and collapse rows using a button in a dedicated column:
Here is the code for the above example:
Head over to the next example to see how you can use the row expansion feature to display nested tables.














