Skip to main content

Hooks

useCollapsibleState

The useCollapsibleState hook can be used to create custom collapsible rows in a table. It requires an id and an array of forRows to manage the state of the collapsible rows. The hook exposes expanded (whether the current row is expanded), expandedIds an array of expanded rows, and handleClickToggle to manage the state of the collapsible rows.

Result
Loading...
Live Editor

"Nested" Collapsible Rows

It's possible to use the hook to create collapsible rows that are conceptually nested within other collapsible rows. Manually calling the setExpandedIds function to remove "nested" rows.

Result
Loading...
Live Editor