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.
Override or extend the styles applied to the component.
See CSS API below for more details.
Type:object
The default icon displayed next to a end node. This is applied to all tree nodes and can be overridden by the TreeItem icon
prop.
Type:node
Expanded node ids. Used when the item's expansion is not controlled.
Type:Array<string>
Default:[]
The default icon displayed next to a parent node. This is applied to all parent nodes and can be overridden by the TreeItem icon
prop.
Type:node
Selected node ids. (Uncontrolled) When multiSelect
is true this takes an array of strings; when false (default) a string.
Type:any
Default:[]
Used to determine the string label for a given item.
Type:func
Default:`(item) => item.id`
function(item: R) => string
item
The item to check.
Returns: The id of the item.
Used to determine the string label for a given item.
Type:func
Default:`(item) => item.label`
function(item: R) => string
item
The item to check.
Returns: The label of the item.
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.
Type:string
Used to determine if a given item should be disabled.
Type:func
function(item: R) => boolean
item
The item to check.
Returns: true
if the item should be disabled.
Callback fired when tree items are expanded/collapsed.
Type:func
function(event: React.SyntheticEvent, nodeIds: array) => void
event
The event source of the callback.nodeIds
The ids of the expanded nodes.
Callback fired when a tree item is expanded or collapsed.
Type:func
function(event: React.SyntheticEvent, nodeId: array, isExpanded: array) => void
event
The event source of the callback.nodeId
The nodeId of the modified node.isExpanded
true
if the node has just been expanded,false
if it has just been collapsed.
Callback fired when tree items are focused.
Type:func
function(event: React.SyntheticEvent, nodeId: string, value: string) => void
event
The event source of the callback Warning: This is a generic event not a focus event.nodeId
The id of the node focused.value
of the focused node.
Callback fired when a tree item is selected or deselected.
Type:func
function(event: React.SyntheticEvent, nodeId: array, isSelected: array) => void
event
The event source of the callback.nodeId
The nodeId of the modified node.isSelected
true
if the node has just been selected,false
if it has just been deselected.
Callback fired when tree items are selected/deselected.
Type:func
function(event: React.SyntheticEvent, nodeIds: Array | string) => void
event
The event source of the callbacknodeIds
The ids of the selected nodes. WhenmultiSelect
istrue
, this is an array of strings; when false (default) a string.
Selected node ids. (Controlled) When multiSelect
is true this takes an array of strings; when false (default) a string.
Type:any
The system prop that allows defining system overrides as well as additional CSS styles.
See the `sx` page for more details.
Type:Array<func
| object
| bool>
| func
| object
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.
These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.
You can override the style of the component using one of these customization options:
- With a global class name.
- With a rule name as part of the component's
styleOverrides
property in a custom theme.