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.

Component demos

Import

import { TreeItem } from '@mui/x-tree-view/TreeItem';
// or
import { TreeItem } from '@mui/x-tree-view';
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.

ContentComponentelement typeTreeItemContent

The component used for the content node.

ContentPropsobject-

Props applied to ContentComponent.

disabledboolfalse

If true, the node is disabled.

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.

slotPropsobject{}

The props used for each component slot.

slotsobject{}

Overridable component slots.

See Slots API below for more details.

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.

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.


Slots

Slot nameClass nameDefault componentDescription
collapseIconThe icon used to collapse the node.
expandIconThe icon used to expand the node.
endIconThe icon displayed next to an end node.
iconThe icon to display next to the tree node's label.
groupTransition.MuiTreeItem-groupTransitionTreeItem2GroupThe component that animates to appearance / disappearance of the item's children.

CSS classes

These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.

Class nameRule nameDescription
.Mui-disabledState class applied to the element when disabled.
.Mui-expandedState class applied to the content element when expanded.
.Mui-focusedState class applied to the content element when focused.
.Mui-selectedState class applied to the content element when selected.
.MuiTreeItem-contentcontentStyles applied to the content element.
.MuiTreeItem-iconContainericonContainerStyles applied to the tree node icon.
.MuiTreeItem-labellabelStyles applied to the label element.
.MuiTreeItem-rootrootStyles applied to the root element.

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