TreeView API
Demos
For examples and details on the usage of this React component, visit the component demo pages:
Import
import TreeView from '@mui/lab/TreeView';
// or
import { TreeView } from '@mui/lab';Props
Props of the native component are also available.
| Name | Type | Default | Description | 
|---|---|---|---|
| children | node | The content of the component. | |
| classes | object | Override or extend the styles applied to the component. See CSS API below for more details. | |
| defaultCollapseIcon | node | The default icon used to collapse the node. | |
| defaultEndIcon | node | The default icon displayed next to a end node. This is applied to all tree nodes and can be overridden by the TreeItem  iconprop. | |
| defaultExpanded | Array<string> | [] | Expanded node ids. (Uncontrolled) | 
| defaultExpandIcon | node | The default icon used to expand the node. | |
| defaultParentIcon | node | The default icon displayed next to a parent node. This is applied to all parent nodes and can be overridden by the TreeItem  iconprop. | |
| defaultSelected | Array<string> | string | [] | Selected node ids. (Uncontrolled) When  multiSelectis true this takes an array of strings; when false (default) a string. | 
| disabledItemsFocusable | bool | false | If  true, will allow focus on disabled items. | 
| disableSelection | bool | false | If  trueselection is disabled. | 
| expanded | Array<string> | Expanded node ids. (Controlled) | |
| 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. | |
| multiSelect | bool | false | If true  ctrlandshiftwill trigger multiselect. | 
| onNodeFocus | func | Callback fired when tree items are focused. Signature: function(event: React.SyntheticEvent, value: string) => voidevent: The event source of the callback Warning: This is a generic event not a focus event. value: of the focused node. | |
| onNodeSelect | func | Callback fired when tree items are selected/unselected. Signature: function(event: React.SyntheticEvent, nodeIds: Array<string> | string) => voidevent: The event source of the callback nodeIds: Ids of the selected nodes. When multiSelectis true this is an array of strings; when false (default) a string. | |
| onNodeToggle | func | Callback fired when tree items are expanded/collapsed. Signature: function(event: React.SyntheticEvent, nodeIds: array) => voidevent: The event source of the callback. nodeIds: The ids of the expanded nodes. | |
| selected | Array<string> | string | Selected node ids. (Controlled) When  multiSelectis true this takes an array of strings; when false (default) a string. | |
| 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. | 
The
ref is forwarded to the root element.Theme default props
You can useMuiTreeView to change the default props of this component with the theme.CSS
The following class names are useful for styling with CSS (the state classes are marked). 
 To learn more, visit the component customization page.
| Rule name | Global class | Description | 
|---|---|---|
| root | .MuiTreeView-root | Styles applied to the root element. | 
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 styleOverridesproperty in a custom theme.