Ids of the items expanded on first render. Not read by `TreeViewItem`: use `defaultExpanded` on the item
variant
"lg" | "md" | "sm"
md
Text size of every item in the tree
TreeView, more props
Prop
Type
Default
Description
expanded / onExpandedChange
string[] / (ids: string[]) => void
—
Controlled open items. Not used by `TreeViewItem` today, see Known issues.
selected / defaultSelected / onSelectedChange
string | null / (id: string | null) => void
—
Selected item. Not used by `TreeViewItem` today, see Known issues.
className
string
—
Extra class on the tree container.
TreeViewItem
Prop
Type
Default
Description
id
string
—
Identifier of the item. Required.
label
ReactNode
—
Text of the item. Required. It is also shown in the tooltip.
leftContent
ReactNode
—
Content before the label, such as an icon.
rightContent
ReactNode
—
Content after the label, such as a count or a Tag.
level
number
0
Depth of the item. Sets the indent. `TreeViewGroup` sets it for you.
defaultExpanded
boolean
false
Starts the item open.
disabled
boolean
—
Prevents interaction with the item.
children
ReactNode
—
Nested items. Their presence adds the chevron.
TreeViewGroup
Prop
Type
Default
Description
items
TreeViewItemData[]
—
Items to render, with optional `children`.
level
number
0
Starting depth.
renderItem
(item, level, defaultRender) => ReactNode
—
Custom render of one item.
Known issues
Issue
Effect
TreeViewItem keeps its own open state and never calls the tree’s toggleExpanded or selectItem.
expanded, onExpandedChange, selected, defaultExpanded and onSelectedChange on TreeView have no effect. There is no way to know or control the selection.
Every item has mb-6 (24px) under a 32px row.
Rows are 56px apart, much more than the row height.
The treeitem wrapper has tabIndex={0} and the button inside has it too.
Two tab stops per item. There is no arrow-key movement between items.
A disabled item only gets the disabled attribute. treeViewItemVariants has no disabled style.
A disabled item looks the same as an enabled one.
Children are not wrapped in role="group", and items do not set aria-selected.
Screen readers do not get the tree structure or the selection.
Every item renders its own TooltipProvider and tooltip.
A tooltip with the label shows even when the label is not cut.