1. framework components
  2. tree view

Tree View

Used to display hierarchical data.

File System

package.json

Controlled

File System

package.json

Multiple Selection

  • Windows: Hold Ctrl + left click with mouse.
  • MacOS: Hold + left click with mouse.

File System

package.json

Collapse and Expand

Use the Provider Pattern to gain access to the collapse and expand methods on the TreeView instance.

File System

package.json

Lazy Loading

File System

package.json

API Reference

Root

Property Default Type
collection -
TreeCollection<any> | undefined
The tree collection data
ids -
Partial<{ root: string; tree: string; label: string; node: (value: string) => string; }> | undefined
The ids of the tree elements. Useful for composition.
expandedValue -
string[] | undefined
The controlled expanded node ids
defaultExpandedValue -
string[] | undefined
The initial expanded node ids when rendered. Use when you don't need to control the expanded node value.
selectedValue -
string[] | undefined
The controlled selected node value
defaultSelectedValue -
string[] | undefined
The initial selected node value when rendered. Use when you don't need to control the selected node value.
defaultCheckedValue -
string[] | undefined
The initial checked node value when rendered. Use when you don't need to control the checked node value.
checkedValue -
string[] | undefined
The controlled checked node value
defaultFocusedValue -
string | null | undefined
The initial focused node value when rendered. Use when you don't need to control the focused node value.
focusedValue -
string | null | undefined
The value of the focused node
selectionMode "single"
"single" | "multiple" | undefined
Whether the tree supports multiple selection - "single": only one node can be selected - "multiple": multiple nodes can be selected
onExpandedChange -
((details: ExpandedChangeDetails<any>) => void) | undefined
Called when the tree is opened or closed
onSelectionChange -
((details: SelectionChangeDetails<any>) => void) | undefined
Called when the selection changes
onFocusChange -
((details: FocusChangeDetails<any>) => void) | undefined
Called when the focused node changes
onCheckedChange -
((details: CheckedChangeDetails) => void) | undefined
Called when the checked value changes
canRename -
((node: any, indexPath: IndexPath) => boolean) | undefined
Function to determine if a node can be renamed
onRenameStart -
((details: RenameStartDetails<any>) => void) | undefined
Called when a node starts being renamed
onBeforeRename -
((details: RenameCompleteDetails) => boolean) | undefined
Called before a rename is completed. Return false to prevent the rename.
onRenameComplete -
((details: RenameCompleteDetails) => void) | undefined
Called when a node label rename is completed
onLoadChildrenComplete -
((details: LoadChildrenCompleteDetails<any>) => void) | undefined
Called when a node finishes loading children
onLoadChildrenError -
((details: LoadChildrenErrorDetails<any>) => void) | undefined
Called when loading children fails for one or more nodes
expandOnClick true
boolean | undefined
Whether clicking on a branch should open it or not
typeahead true
boolean | undefined
Whether the tree supports typeahead search
loadChildren -
((details: LoadChildrenDetails<any>) => Promise<any[]>) | undefined
Function to load children for a node asynchronously. When provided, branches will wait for this promise to resolve before expanding.
dir "ltr"
"ltr" | "rtl" | undefined
The document's text/writing direction.
getRootNode -
(() => ShadowRoot | Node | Document) | undefined
A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.
element -
Snippet<[HTMLAttributes<"div">]> | undefined
Render the element yourself

RootProvider

Property Default Type
value -
() => TreeViewApi<PropTypes, any>
element -
Snippet<[HTMLAttributes<"div">]> | undefined
Render the element yourself

RootContext

Property Default Type
children -
Snippet<[() => TreeViewApi<PropTypes, any>]>

Tree

Property Default Type
element -
Snippet<[HTMLAttributes<"div">]> | undefined
Render the element yourself

Label

Property Default Type
level -
1 | 2 | 3 | 4 | 5 | 6 | undefined
The level of the heading.
element -
Snippet<[HTMLAttributes<"h3">]> | undefined
Render the element yourself

NodeProvider

Property Default Type
value -
NodeProps
children -
Snippet<[]> | undefined
The default slot content to be rendered within the component.

Branch

Property Default Type
element -
Snippet<[HTMLAttributes<"div">]> | undefined
Render the element yourself

BranchControl

Property Default Type
element -
Snippet<[HTMLAttributes<"div">]> | undefined
Render the element yourself

BranchText

Property Default Type
element -
Snippet<[HTMLAttributes<"span">]> | undefined
Render the element yourself

BranchIndicator

Property Default Type
element -
Snippet<[HTMLAttributes<"span">]> | undefined
Render the element yourself

BranchContent

Property Default Type
element -
Snippet<[HTMLAttributes<"div">]> | undefined
Render the element yourself

BranchIndentGuide

Property Default Type
element -
Snippet<[HTMLAttributes<"div">]> | undefined
Render the element yourself

Item

Property Default Type
element -
Snippet<[HTMLAttributes<"div">]> | undefined
Render the element yourself