Skip to components
DEVELOPER REFERENCE

Tree API

Props, callbacks and methods. Select an underlined type to explore its fields, allowed values and callback arguments.

Tree8 props2 callbacks0 methods

Preset and CSS

Set preset.className to attach your CSS class to the component's rendered surface. Explicit component props take precedence over preset options.

CSS parts in the example [data-part="item"] [data-part="label"] [data-part="root"]

Use styles.root and styles.parts in a theme and generate a CSS file with themeToCss. For other JSON-friendly component props, spread presetProps(preset) before explicit props. Parts and states depend on configuration; the gallery shows those visible in the current preview.

Props8

Tree props
NameTypeDescription
nodesRequired
readonly TreeNode[]Inspect type
Root nodes in display order.
labelRequiredstringAccessible name for the tree.
valueOptionalstring | undefinedControlled selected node ID.
defaultValueOptionalstring | undefinedInitially selected node ID when uncontrolled.
expandedOptional
readonly string[] | undefinedInspect type
Controlled IDs of expanded branches.
defaultExpandedOptional
readonly string[] | undefinedInspect type
Initially expanded branch IDs when uncontrolled.
presetOptional
ClassPreset | undefinedInspect type
Optional shared presentation preset.
classNameOptionalstring | undefinedAdditional root class names.

Events and callbacks2

Tree events and callbacks
NameTypeDescription
onValueChangeOptional
((id: string) => void) | undefinedInspect type
Called after an enabled node is selected.
onExpandedChangeOptional
((ids: string[]) => void) | undefinedInspect type
Called with expanded branch IDs after disclosure changes.

Methods0

No component-specific imperative methods. Use props and callbacks to control this component.