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';
Learn about the difference by reading this guide on minimizing bundle size.

Props

Props of the native component are also available.

nodeIdRequired

The id of the node.

Type:

string
children

The content of the component.

Type:

node
classes

Override or extend the styles applied to the component.

Type:

object
collapseIcon

The icon used to collapse the node.

Type:

node
ContentComponent

The component used for the content node.

Type:

element type

Default:

TreeItemContent
ContentProps

Props applied to ContentComponent

Type:

object
disabled

If true, the node is disabled.

Type:

bool

Default:

false
endIcon

The icon displayed next to a end node.

Type:

node
expandIcon

The icon used to expand the node.

Type:

node
icon

The icon to display next to the tree node's label.

Type:

node
label

The tree node label.

Type:

node
onFocus

This prop isn't supported. Use the onNodeFocus callback on the tree if you need to monitor a node's focus.

Type:

unsupportedProp
sx

The system prop that allows defining system overrides as well as additional CSS styles.

Type:

Array<func | object | bool> | func | object
TransitionComponent

The component used for the transition. Follow this guide to learn more about the requirements for this component.

Type:

elementType

Default:

Collapse
TransitionProps

Props applied to the transition element. By default, the element is based on this Transition component.

Type:

object

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.

.MuiTreeItem-rootroot

Styles applied to the root element.

.MuiTreeItem-groupgroup

Styles applied to the transition component.

.MuiTreeItem-contentcontent

Styles applied to the content element.

.Mui-expandedexpandedSTATE

State class applied to the content element when expanded.

.Mui-selectedselectedSTATE

State class applied to the content element when selected.

.Mui-focusedfocusedSTATE

State class applied to the content element when focused.

.Mui-disableddisabledSTATE

State class applied to the element when disabled.

.MuiTreeItem-iconContainericonContainer

Styles applied to the tree node icon.

.MuiTreeItem-labellabel

Styles applied to the label element.

You can override the style of the component using one of these customization options: