SimpleTreeView API
API reference docs for the React SimpleTreeView component. Learn about the props, CSS, and other APIs of this exported module.
Component demos
Import
import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';
// or
import { SimpleTreeView } 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- itemThe 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- itemThe 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
Callback fired when tree items are expanded/collapsed.
Type:func
function(event: React.SyntheticEvent, nodeIds: array) => void- eventThe event source of the callback.
- nodeIdsThe 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- eventThe event source of the callback.
- nodeIdThe nodeId of the modified node.
- isExpanded- trueif the node has just been expanded,- falseif it has just been collapsed.
Callback fired when tree items are focused.
Type:func
function(event: React.SyntheticEvent, nodeId: string, value: string) => void- eventThe event source of the callback Warning: This is a generic event not a focus event.
- nodeIdThe id of the node focused.
- valueof the focused node.
Callback fired when a tree item is selected or deselected.
Type:func
function(event: React.SyntheticEvent, nodeId: array, isSelected: array) => void- eventThe event source of the callback.
- nodeIdThe nodeId of the modified node.
- isSelected- trueif the node has just been selected,- falseif it has just been deselected.
Callback fired when tree items are selected/deselected.
Type:func
function(event: React.SyntheticEvent, nodeIds: Array | string) => void - eventThe event source of the callback
- nodeIdsThe ids of the selected nodes. When- multiSelectis- true, 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 MuiSimpleTreeView 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 styleOverridesproperty in a custom theme.