Перейти к контенту

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';
// или
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

Props of the native component are also available.

ИмяТипПо-умолчаниюОписание
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.
sxobject
The system prop that allows defining system overrides as well as additional CSS styles. See the `sx` page for more details.
TransitionComponentelementTypeCollapse
Компонент, используемый в анимации сворачивания. Прочтите это руководство, чтобы узнать больше о требованиях к этому компоненту.
TransitionPropsobject
Свойства, передаваемые в анимируемый компонент. По умолчанию элемент основывается на компоненте Transition.

The ref is forwarded to the root element.

CSS

Rule nameGlobal classОписание
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:

Demos