TreeView

Tree views can be used to represent a file system navigator displaying folders and files, an item representing a folder can be expanded to reveal the contents of the folder, which may be files, folders, or both.

<TreeView
defaultCollapseIcon={<ArrowDown />}
defaultExpandIcon={<ArrowRight />}
>
<TreeItem nodeId="1" label="Applications">
<TreeItem nodeId="2" label="Calendar" />
<TreeItem nodeId="3" label="Chrome" />
<TreeItem nodeId="4" label="Webstorm" />
</TreeItem>
<TreeItem nodeId="5" label="Documents">
<TreeItem nodeId="10" label="OSS" />
<TreeItem nodeId="6" label="Material-UI">
<TreeItem nodeId="7" label="src">
<TreeItem nodeId="8" label="index.js" />
<TreeItem nodeId="9" label="tree-view.js" />
</TreeItem>
</TreeItem>
</TreeItem>
</TreeView>

Props

PropTypeDefaultDescription
childrennodeThe content of the component.
classesobjectOverride or extend the styles applied to the component. See CSS API below for more details.
defaultCollapseIconnodeThe default icon used to collapse the node.
defaultEndIconnodeThe default icon displayed next to a end node. This is applied to all tree nodes and can be overridden by the TreeItem icon prop.
defaultExpandedArray<string>[]Expanded node ids. (Uncontrolled).
defaultExpandIconnodeThe default icon used to expand the node.
defaultParentIconnodeThe default icon displayed next to a parent node. This is applied to all parent nodes and can be overridden by the TreeItem icon prop.
defaultSelectedArray<string> | string[]Selected node ids. (Uncontrolled) When multiSelect is true this takes an array of strings; when false (default) a string.
disableSelectionboolfalseIf true selection is disabled.
expandedArray<string>falseExpanded node ids. (Controlled).
multiSelectboolfalseIf true ctrl and shift will trigger multiselect.
onNodeSelectfunc'medium'Callback fired when tree items are selected/unselected. Signature:function(event: object, value: array | string) => void event: The event source of the callback value: of the selected nodes. When multiSelect is true this is an array of strings; when false (default) a string.
onNodeTogglefuncCallback fired when tree items are expanded/collapsed. Signature:function(event: object, nodeIds: array) => void event: The event source of the callback.nodeIds: The ids of the expanded nodes.
selectedArray<string> | stringSelected node ids. (Controlled) When multiSelect is true this takes an array of strings; when false (default) a string.