Rich Tree View - Expansion
Handle how users can expand items.
Controlled expansion
Use the expandedItems
prop to control the expanded items.
You can use the onExpandedItemsChange
prop to listen to changes in the expanded items and update the prop accordingly.
- Data Grid
- Date and Time Pickers
- Charts
- Tree View
Press Enter to start editing
Track item expansion change
Use the onItemExpansionToggle
prop if you want to react to an item expansion change:
No action recorded
- Data Grid
- Date and Time Pickers
- Charts
- Tree View
Press Enter to start editing
Limit expansion to icon container
You can use the expansionTrigger
prop to decide if the expansion interaction should be triggered by clicking on the icon container instead of the whole Tree Item content.
- Data Grid
- Date and Time Pickers
- Charts
- Tree View
Press Enter to start editing
Imperative API
Change an item expansion
Use the setItemExpansion
API method to change the expansion of an item.
apiRef.current.setItemExpansion(
// The DOM event that triggered the change
event,
// The ID of the item to expand or collapse
itemId,
// `true` if the item should be expanded, `false` if it should be collapsed
isExpanded,
);
- Data Grid
- Date and Time Pickers
- Charts
- Tree View
Press Enter to start editing
API
See the documentation below for a complete reference to all of the props and classes available to the components mentioned here.