Skip to content

TreeItem API

API reference docs for the React TreeItem component. Learn about the props, CSS, and other APIs of this exported module.

Demos

For examples and details on the usage of this React component, visit the component demo pages:

Import

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

Props

Props of the native component are also available.

NameTypeDefaultDescription
nodeId*string
The id of the node.
childrennode
The content of the component.
classesobject
Override or extend the styles applied to the component. See CSS API below for more details.
collapseIconnode
The icon used to collapse the node.
ContentComponentelement typeTreeItemContent
The component used for the content node.
⚠️ Needs to be able to hold a ref.
ContentPropsobject
Props applied to ContentComponent
disabledboolfalse
If true, the node is disabled.
endIconnode
The icon displayed next to a end node.
expandIconnode
The icon used to expand the node.
iconnode
The icon to display next to the tree node's label.
labelnode
The tree node label.
onFocusunsupportedProp
This prop isn't supported. Use the onNodeFocus callback on the tree if you need to monitor a node's focus.
sxArray<func
| object
| bool>
| func
| object
The system prop that allows defining system overrides as well as additional CSS styles. See the `sx` page for more details.
TransitionComponentelementTypeCollapse
The component used for the transition. Follow this guide to learn more about the requirements for this component.
TransitionPropsobject
Props applied to the transition element. By default, the element is based on this Transition component.

The ref is forwarded to the root element.

Theme default props

You can use MuiTreeItem 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.

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
STATE
.Mui-expandedState class applied to the content element when expanded.
selected
STATE
.Mui-selectedState class applied to the content element when selected.
focused
STATE
.Mui-focusedState class applied to the content element when focused.
disabled
STATE
.Mui-disabledState 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: