Skip to content

TreeItem API

API documentation for the React TreeItem component. Learn about the available props, and the CSS API.

Import

import TreeItem from '@material-ui/lab/TreeItem';
// or
import { TreeItem } from '@material-ui/lab';
You can learn about the difference by reading this guide on minimizing bundle size.

Component name

The name MuiTreeItem can be used when providing default props or style overrides in the theme.

Props

NameTypeDefaultDescription
nodeId*stringThe id of the node.
childrennodeThe content of the component.
classesobjectOverride or extend the styles applied to the component. See CSS API below for more details.
collapseIconnodeThe icon used to collapse the node.
ContentComponentelement typeTreeItemContentThe component used for the content node.
⚠️ Needs to be able to hold a ref.
ContentPropsobjectProps applied to ContentComponent
disabledboolfalseIf true, the node is disabled.
endIconnodeThe icon displayed next to a end node.
expandIconnodeThe icon used to expand the node.
iconnodeThe icon to display next to the tree node's label.
labelnodeThe tree node label.
onFocusunsupportedPropThis prop isn't supported. Use the onNodeFocus callback on the tree if you need to monitor a node's focus.
TransitionComponentelementTypeCollapseThe component used for the transition. Follow this guide to learn more about the requirements for this component.
TransitionPropsobjectProps applied to the transition element. By default, the element is based on this Transition component.

The ref is forwarded to the root element.
Any other props supplied will be provided to the root element (native element).

CSS

Rule nameGlobal classDescription
root.MuiTreeItem-rootStyles applied to the root element.
group.MuiTreeItem-groupStyles applied to the transition component.
content.MuiTreeItem-contentStyles applied to the content element.
expanded.Mui-expandedPseudo-class applied to the content element when expanded.
selected.Mui-selectedPseudo-class applied to the content element when selected.
focused.Mui-focusedPseudo-class applied to the content element when focused.
disabled.Mui-disabledPseudo-class applied to the element when disabled.
iconContainer.MuiTreeItem-iconContainerStyles applied to the tree node icon.
label.MuiTreeItem-labelStyles applied to the label element.

You can override the style of the component using one of these customization options: If that isn't sufficient, you can check the implementation of the component for more detail.

Demos