RichTreeView API
API reference docs for the React RichTreeView component. Learn about the props, CSS, and other APIs of this exported module.
Component demos
Import
import { RichTreeView } from '@mui/x-tree-view/RichTreeView';
// or
import { RichTreeView } from '@mui/x-tree-view';Props of the native component are also available.
| Name | Type | Default | Description | 
|---|---|---|---|
| classes | object | - | Override or extend the styles applied to the component. See CSS API below for more details. | 
| defaultExpandedNodes | Array<string> | [] | Expanded node ids. Used when the item's expansion is not controlled. | 
| defaultSelectedNodes | any | [] | Selected node ids. (Uncontrolled) When  | 
| disabledItemsFocusable | bool | false | If  | 
| disableSelection | bool | false | If  | 
| expandedNodes | Array<string> | - | Expanded node ids. Used when the item's expansion is controlled. | 
| getItemId | func | `(item) => item.id` | Used to determine the string label for a given item. Signature: function(item: R) => string
 Returns: The id of the item. | 
| getItemLabel | func | `(item) => item.label` | Used to determine the string label for a given item. Signature: function(item: R) => string
 Returns: The label of the item. | 
| id | string | - | This prop is used to help implement the accessibility logic. If you don't provide this prop. It falls back to a randomly generated id. | 
| isItemDisabled | func | - | Used to determine if a given item should be disabled. Signature: function(item: R) => boolean
 Returns:  | 
| multiSelect | bool | false | If true  | 
| onExpandedNodesChange | func | - | Callback fired when tree items are expanded/collapsed. Signature: function(event: React.SyntheticEvent, nodeIds: array) => void
 | 
| onNodeExpansionToggle | func | - | Callback fired when a tree item is expanded or collapsed. Signature: function(event: React.SyntheticEvent, nodeId: array, isExpanded: array) => void
 | 
| onNodeFocus | func | - | Callback fired when tree items are focused. Signature: function(event: React.SyntheticEvent, nodeId: string, value: string) => void
 | 
| onNodeSelectionToggle | func | - | Callback fired when a tree item is selected or deselected. Signature: function(event: React.SyntheticEvent, nodeId: array, isSelected: array) => void
 | 
| onSelectedNodesChange | func | - | Callback fired when tree items are selected/deselected. Signature: function(event: React.SyntheticEvent, nodeIds: Array
 | 
| selectedNodes | any | - | Selected node ids. (Controlled) When  | 
| slotProps | object | {} | The props used for each component slot. | 
| slots | object | {} | Overridable component slots. See Slots API below for more details. | 
| sx | Array<func | object | bool> | func | object | - | The system prop that allows defining system overrides as well as additional CSS styles. See the `sx` page for more details. | 
ref is forwarded to the root element.Theme default props
You can use MuiRichTreeView to change the default props of this component with the theme.
| Slot name | Class name | Default component | Description | 
|---|---|---|---|
| root | .MuiRichTreeView-root | RichTreeViewRoot | Element rendered at the root. | 
| item | TreeItem. | Custom component for the item. | |
| collapseIcon | The default icon used to collapse the node. | ||
| expandIcon | The default icon used to expand the node. | ||
| endIcon | The default icon displayed next to an end node. This is applied to all tree nodes and can be overridden by the TreeItem iconslot prop. |