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.
Override or extend the styles applied to the component.
See CSS API below for more details.
Type:
objectThe 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:
nodeThe 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:
nodeSelected node ids. (Uncontrolled) When multiSelect is true this takes an array of strings; when false (default) a string.
Type:
Array<string> | stringDefault:
[]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:
stringCallback fired when tree items are focused.
Type:
funcSignature:
function(event: React.SyntheticEvent, value: string) => voideventThe event source of the callback Warning: This is a generic event not a focus event.valueof the focused node.
Callback fired when tree items are selected/unselected.
Type:
funcSignature:
function(event: React.SyntheticEvent, nodeIds: Array | string) => void eventThe event source of the callbacknodeIdsIds of the selected nodes. WhenmultiSelectis true this is an array of strings; when false (default) a string.
Callback fired when tree items are expanded/collapsed.
Type:
funcSignature:
function(event: React.SyntheticEvent, nodeIds: array) => voideventThe event source of the callback.nodeIdsThe ids of the expanded nodes.
Selected node ids. (Controlled) When multiSelect is true this takes an array of strings; when false (default) a string.
Type:
Array<string> | stringThe 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 | objectref is forwarded to the root element.Theme default props
You can use MuiTreeView 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.
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.