File Explorer Basic - Expansion
Learn how to handle expanding and collapsing File Explorer items.
Controlled expansion
Use the expandedItems
prop to control the expanded items.
You can also use the onExpandedItemsChange
prop to listen to changes in the expanded items and update the prop accordingly.
- Notes
- Images
- Movies
- Data
Track item expansion change
Use the onItemExpansionToggle
prop to trigger an action upon an item being expanded.
No action recorded
- Data Grid
- Date and Time Pickers
- Charts
- File Explorer
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.
- Notes
- Images
- Movies
- Data
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,
// If `true` the item will be expanded
// If `false` the item will be collapsed
isExpanded,
);
- Notes
- Images
- Movies
- Data