TreeView API
The API documentation of the TreeView React component. Learn more about the properties and the CSS customization points.
import TreeView from '@material-ui/lab/TreeView';
Props
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 icon prop. |
|
defaultExpanded | arrayOf | [] | Expanded node ids. |
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 icon prop. |
|
onNodeToggle | func | Callback fired when a TreeItem is expanded/collapsed.Signature: function(nodeId: string, expanded: boolean) => void nodeId: The id of the toggled node. expanded: The node status - If true the node was expanded. If false the node was collapsed. |
The ref
is forwarded to the root element.
Any other properties supplied will be provided to the root element (native element).
CSS
You can override all the class names injected by Material-UI thanks to the classes
prop.
This prop accepts the following keys:
Name | Description |
---|---|
root | Styles applied to the root component. |
Have a look at the overriding styles with classes section and the implementation of the component for more detail.
If using the overrides
key of the theme,
you need to use the following style sheet name: MuiTreeView
.
Notes
The component can cause issues in StrictMode.