Tree

import {Tree} from "@qualcomm-ui/react/tree"

Overview

  • The tree relies on the TreeCollection class to manage its items. Refer to the API below for details.
  • Trees are composed of nodes, which are objects that describe the tree data. There are two types of nodes:
    • A branch node is a node that has children.
    • A leaf node is a node that does not have any children.
  • Each node has a value (unique identifier used for selection/expansion) and a text (display text).

Default object shape:

  • value (required): unique identifier for expansion/selection
  • text (required): display text
  • nodes (optional): child nodes for branches
  • disabled (optional): prevents interaction when true

These defaults can be overridden in the TreeCollection constructor.

Examples

Node Shorthand

We expose the <Tree.Nodes> shorthand for rendering Branch and Leaf nodes. Use its renderBranch and renderLeaf render props to customize the content of each tree item.

Note that <Tree.Nodes> automatically renders child nodes for branches, so you only have to customize the content of the node itself.

prettier.config.js
package.json
tsconfig.json

Nodes

You can bring your own TreeNodes to create your own abstraction for the tree.

NOTE

This approach is recommended only for advanced use cases. Most users should use the shorthand <Tree.Nodes> instead.

prettier.config.js
package.json
tsconfig.json

Default Expanded

Expand nodes by default using the defaultExpandedValue prop. Or use expandedValue and onExpandedChange to control the expansion manually. These props follow our controlled state pattern.

src
app.tsx
index.ts
prettier.config.js
package.json
tsconfig.json
<Tree.Root
  className="w-full max-w-sm"
  collection={collection}
  defaultExpandedValue={["src"]}
>

Checkbox Trees

Use the Tree.CheckboxNode to create a checkbox tree. The checked state of the tree can be controlled using the checkedValue, onCheckedChange, and defaultCheckedValue props, which follow our controlled state pattern.

Qualcomm
Intel
AMD
<Tree.Nodes
  key={node.id}
  indexPath={[index]}
  node={node}
  renderBranch={({node}) => (
    <Tree.BranchNode>
      <Tree.BranchTrigger />
      <Tree.NodeCheckbox />
      <Tree.NodeText>{node.text}</Tree.NodeText>
    </Tree.BranchNode>
  )}
  renderLeaf={({node}) => (
    <Tree.LeafNode>
      <Tree.NodeCheckbox />
      <Tree.NodeText>{node.text}</Tree.NodeText>
    </Tree.LeafNode>
  )}
/>

Checkbox selection state

The Tree handles nested checkbox selection automatically:

  • If all of a node's children are checked, the node will also be checked.
  • If only some of a node's children are checked, the node will appear indeterminate to indicate partial selection.

When you supply the checkedValue or defaultCheckedValue props, you must account for the above logic.

Disabled Nodes

You can disable nodes by setting the disabled property on the node object.

prettier.config.js
package.json
renovate.json
tsconfig.json

Filtering

Here's an example that filters the nodes using matchSorter.

prettier.config.js
package.json
tsconfig.json

Tree nodes can be links using polymorphic composition. Use the render prop on the <Tree.BranchNode> or <Tree.LeafNode> to specify the element type.

<Tree.LeafNode
  render={node.pathname ? <Link to={node.pathname} /> : <div />}
>
  <Tree.NodeIndicator />
  <Tree.NodeText>{node.name}</Tree.NodeText>
</Tree.LeafNode>

Sizes

Tree item sizes are controlled using the size prop on the root of the tree.

Small (sm)
prettier.config.js
package.json
tsconfig.json
Medium (md)
prettier.config.js
package.json
tsconfig.json

Add / Remove nodes

The TreeCollection class exposes methods to handle the addition and removal of nodes. Here's an example of how to use them.

prettier.config.js
package.json
tsconfig.json

API

<Tree.Root>

Groups all parts of the tree. Renders a <div> element by default.
PropTypeDefault
The controlled checked node value
string[]
The tree collection data
The initial checked node value when rendered. Use when you don't need to control the checked node value.
string[]
The initial expanded node ids when rendered. Use when you don't need to control the expanded node value.
string[]
The initial focused node value when rendered. Use when you don't need to control the focused node value.
string
The initial selected node value when rendered. Use when you don't need to control the selected node value.
string[]
The document's text/writing direction.
'ltr' | 'rtl'
'ltr'
The controlled expanded node ids
string[]
Whether clicking on a branch should open it or not
boolean
true
The value of the focused node
string
A root node to correctly resolve document in custom environments. i.e., Iframes, Electron.
      () =>
      | Node
      | ShadowRoot
      | Document
      id attribute. If omitted, a unique identifier will be automatically generated for accessibility.
      string
      When true, the component will not be rendered in the DOM until it becomes visible or active.
      boolean
      false
      
      Function to load children for a node asynchronously. When provided, branches will wait for this promise to resolve before expanding.
          (details: {
          indexPath: number[]
          node: T
          signal: AbortSignal
          valuePath: string[]
          }) => Promise<Array<T>>
          Called when the checked value changes
              (details: {
              checkedNodes: Array<T>
              checkedValue: string[]
              }) => void
              Called when the tree is opened or closed
                  (details: {
                  expandedNodes: Array<T>
                  expandedValue: string[]
                  focusedValue: string
                  }) => void
                  Called when the focused node changes
                      (details: {
                      focusedNode: T
                      focusedValue: string
                      }) => void
                      Called when a node finishes loading children
                          (details: {
                          collection: TreeCollection<T>
                          }) => void
                          Called when loading children fails for one or more nodes
                              (details: {
                              nodes: NodeWithError[]
                              }) => void
                              Called when the selection changes
                                  (details: {
                                  focusedValue: string
                                  selectedNodes: Array<T>
                                  selectedValue: string[]
                                  }) => void
                                  Allows you to replace the component's HTML element with a different tag or component. Learn more
                                  | ReactElement
                                  | ((
                                  props: object,
                                  ) => ReactElement)
                                  The controlled selected node value
                                  string[]
                                  Whether the tree supports multiple selection
                                  • 'single': only one node can be selected
                                  • 'multiple': multiple nodes can be selected
                                  | 'multiple'
                                  | 'single'
                                  'single'
                                  
                                  Callback function that determines whether a node should be hidden.
                                      (
                                      state: NodeState<T>,
                                      ) => boolean
                                      The size of the tree and its elements. Governs properties like font size, item padding, and icon sizes.
                                      'sm' | 'md'
                                      'md'
                                      
                                      Whether the tree supports typeahead search
                                      boolean
                                      true
                                      
                                      When true, the component will be completely removed from the DOM when it becomes inactive or hidden, rather than just being hidden with CSS.
                                      boolean
                                      false
                                      
                                      Type
                                      string[]
                                      Description
                                      The controlled checked node value
                                      Description
                                      The tree collection data
                                      Type
                                      string[]
                                      Description
                                      The initial checked node value when rendered. Use when you don't need to control the checked node value.
                                      Type
                                      string[]
                                      Description
                                      The initial expanded node ids when rendered. Use when you don't need to control the expanded node value.
                                      Type
                                      string
                                      Description
                                      The initial focused node value when rendered. Use when you don't need to control the focused node value.
                                      Type
                                      string[]
                                      Description
                                      The initial selected node value when rendered. Use when you don't need to control the selected node value.
                                      Type
                                      'ltr' | 'rtl'
                                      Description
                                      The document's text/writing direction.
                                      Type
                                      string[]
                                      Description
                                      The controlled expanded node ids
                                      Type
                                      boolean
                                      Description
                                      Whether clicking on a branch should open it or not
                                      Type
                                      string
                                      Description
                                      The value of the focused node
                                      Type
                                      () =>
                                      | Node
                                      | ShadowRoot
                                      | Document
                                      Description
                                      A root node to correctly resolve document in custom environments. i.e., Iframes, Electron.
                                          Type
                                          string
                                          Description
                                          id attribute. If omitted, a unique identifier will be automatically generated for accessibility.
                                          Type
                                          boolean
                                          Description
                                          When true, the component will not be rendered in the DOM until it becomes visible or active.
                                          Type
                                          (details: {
                                          indexPath: number[]
                                          node: T
                                          signal: AbortSignal
                                          valuePath: string[]
                                          }) => Promise<Array<T>>
                                          Description
                                          Function to load children for a node asynchronously. When provided, branches will wait for this promise to resolve before expanding.
                                              Type
                                              (details: {
                                              checkedNodes: Array<T>
                                              checkedValue: string[]
                                              }) => void
                                              Description
                                              Called when the checked value changes
                                                  Type
                                                  (details: {
                                                  expandedNodes: Array<T>
                                                  expandedValue: string[]
                                                  focusedValue: string
                                                  }) => void
                                                  Description
                                                  Called when the tree is opened or closed
                                                      Type
                                                      (details: {
                                                      focusedNode: T
                                                      focusedValue: string
                                                      }) => void
                                                      Description
                                                      Called when the focused node changes
                                                          Type
                                                          (details: {
                                                          collection: TreeCollection<T>
                                                          }) => void
                                                          Description
                                                          Called when a node finishes loading children
                                                              Type
                                                              (details: {
                                                              nodes: NodeWithError[]
                                                              }) => void
                                                              Description
                                                              Called when loading children fails for one or more nodes
                                                                  Type
                                                                  (details: {
                                                                  focusedValue: string
                                                                  selectedNodes: Array<T>
                                                                  selectedValue: string[]
                                                                  }) => void
                                                                  Description
                                                                  Called when the selection changes
                                                                      Type
                                                                      | ReactElement
                                                                      | ((
                                                                      props: object,
                                                                      ) => ReactElement)
                                                                      Description
                                                                      Allows you to replace the component's HTML element with a different tag or component. Learn more
                                                                      Type
                                                                      string[]
                                                                      Description
                                                                      The controlled selected node value
                                                                      Type
                                                                      | 'multiple'
                                                                      | 'single'
                                                                      Description
                                                                      Whether the tree supports multiple selection
                                                                      • 'single': only one node can be selected
                                                                      • 'multiple': multiple nodes can be selected
                                                                      Type
                                                                      (
                                                                      state: NodeState<T>,
                                                                      ) => boolean
                                                                      Description
                                                                      Callback function that determines whether a node should be hidden.
                                                                          Type
                                                                          'sm' | 'md'
                                                                          Description
                                                                          The size of the tree and its elements. Governs properties like font size, item padding, and icon sizes.
                                                                          Type
                                                                          boolean
                                                                          Description
                                                                          Whether the tree supports typeahead search
                                                                          Type
                                                                          boolean
                                                                          Description
                                                                          When true, the component will be completely removed from the DOM when it becomes inactive or hidden, rather than just being hidden with CSS.

                                                                          <Tree.Nodes>

                                                                          A helper component that renders recursive tree nodes. Doesn't render its own HTML element.
                                                                          PropTypeDefault
                                                                          The index path of the tree node
                                                                          number[]
                                                                          The tree node to apply context from.
                                                                          T
                                                                          Render Prop for the tree's branch items. Use this prop to supply the content of the branch item like the text, indicator, or icon.
                                                                          Render Prop for the tree's leaf items. Use this prop to supply the content of the leaf item like the text, indicator, or icon.
                                                                          Props passed to the branch indent guide component. Only applicable when showIndentGuide is true.
                                                                          Whether to render the indent guide for branch child nodes.
                                                                          boolean
                                                                          false
                                                                          
                                                                          Type
                                                                          number[]
                                                                          Description
                                                                          The index path of the tree node
                                                                          Type
                                                                          T
                                                                          Description
                                                                          The tree node to apply context from.
                                                                          Description
                                                                          Render Prop for the tree's branch items. Use this prop to supply the content of the branch item like the text, indicator, or icon.
                                                                          Description
                                                                          Render Prop for the tree's leaf items. Use this prop to supply the content of the leaf item like the text, indicator, or icon.
                                                                          Description
                                                                          Props passed to the branch indent guide component. Only applicable when showIndentGuide is true.
                                                                          Type
                                                                          boolean
                                                                          Description
                                                                          Whether to render the indent guide for branch child nodes.

                                                                          TreeCollection

                                                                          Note that the TreeCollection accepts a single generic type parameter, T, which is the object type of the node used in the collection.

                                                                          Constructor

                                                                          The constructor of the TreeCollection class accepts the following options:

                                                                          PropTypeDefault
                                                                          Property key for accessing a node's children.
                                                                          keyof T
                                                                          "nodes"
                                                                          
                                                                          Function to determine the count of a node's children.
                                                                              (
                                                                              node: T,
                                                                              ) => number
                                                                              Property key or function to determine if a node is disabled. When a string key is provided, the value of node[key] determines the disabled state.
                                                                              | keyof T
                                                                              | ((node: T) => boolean)
                                                                              "disabled"
                                                                              
                                                                              Property key or function for getting a node's text. When a string key is provided, the value of node[key] is used.
                                                                              | keyof T
                                                                              | ((node: T) => string)
                                                                              "text"
                                                                              
                                                                              Property key or function for getting a node's value. When a string key is provided, the value of node[key] is used.
                                                                              | keyof T
                                                                              | ((node: T) => string)
                                                                              "value"
                                                                              
                                                                              The root node of the tree
                                                                              T
                                                                              Type
                                                                              keyof T
                                                                              Description
                                                                              Property key for accessing a node's children.
                                                                              Type
                                                                              (
                                                                              node: T,
                                                                              ) => number
                                                                              Description
                                                                              Function to determine the count of a node's children.
                                                                                  Type
                                                                                  | keyof T
                                                                                  | ((node: T) => boolean)
                                                                                  Description
                                                                                  Property key or function to determine if a node is disabled. When a string key is provided, the value of node[key] determines the disabled state.
                                                                                  Type
                                                                                  | keyof T
                                                                                  | ((node: T) => string)
                                                                                  Description
                                                                                  Property key or function for getting a node's text. When a string key is provided, the value of node[key] is used.
                                                                                  Type
                                                                                  | keyof T
                                                                                  | ((node: T) => string)
                                                                                  Description
                                                                                  Property key or function for getting a node's value. When a string key is provided, the value of node[key] is used.
                                                                                  Type
                                                                                  T
                                                                                  Description
                                                                                  The root node of the tree
                                                                                  PropType
                                                                                  Gets the node at the specified index path.
                                                                                  • indexPathArray of indices representing the path to the node
                                                                                    (
                                                                                    indexPath: number[],
                                                                                    ) => T
                                                                                    Checks if a parent index path contains a child index path.
                                                                                    • parentIndexPathThe parent path
                                                                                    • valueIndexPathThe child path to check
                                                                                      (
                                                                                      parentIndexPath: number[],
                                                                                      valueIndexPath: number[],
                                                                                      ) => boolean
                                                                                      Creates a new tree collection with the same options but different root node.
                                                                                      • rootNodeThe new root node for the copied collection
                                                                                        (
                                                                                        rootNode: T,
                                                                                        ) => any
                                                                                        Filters the tree keeping only nodes that match the predicate.
                                                                                        • predicateFunction to test each node
                                                                                          (
                                                                                          predicate: (
                                                                                          node: T,
                                                                                          indexPath: number[],
                                                                                          ) => boolean,
                                                                                          ) => any
                                                                                          Finds the first node with the specified value.
                                                                                          • valueThe value to search for
                                                                                          • rootNodeThe root node to start searching from
                                                                                            (
                                                                                            value: string,
                                                                                            rootNode?: T,
                                                                                            ) => T
                                                                                            (
                                                                                            predicate: (
                                                                                            node: T,
                                                                                            indexPath: number[],
                                                                                            ) => boolean,
                                                                                            rootNode?: T,
                                                                                            ) => T
                                                                                            Finds all nodes with values matching the provided array.
                                                                                            • valuesArray of values to search for
                                                                                            • rootNodeThe root node to start searching from
                                                                                              (
                                                                                              values: string[],
                                                                                              rootNode?: T,
                                                                                              ) => Array<T>
                                                                                              Flattens the tree into an array with parent/child relationships.
                                                                                              • rootNodeThe root node to start flattening from
                                                                                                (
                                                                                                rootNode?: T,
                                                                                                ) => Array<
                                                                                                T & {
                                                                                                _children: number[]
                                                                                                _index: number
                                                                                                _parent: number
                                                                                                }
                                                                                                >
                                                                                                Gets all branch node values with optional depth filtering.
                                                                                                • rootNodeThe root node to start from
                                                                                                • optsOptions for skipping nodes and filtering by depth
                                                                                                  (
                                                                                                  rootNode?: T,
                                                                                                  opts?: {
                                                                                                  skip?: (args: {
                                                                                                  indexPath: number[]
                                                                                                  node: T
                                                                                                  value: string
                                                                                                  }) => boolean | void
                                                                                                  } & {
                                                                                                  depth?:
                                                                                                  | number
                                                                                                  | ((
                                                                                                  nodeDepth: number,
                                                                                                  ) => boolean)
                                                                                                  },
                                                                                                  ) => string[]
                                                                                                  Gets the depth of a node with the specified value.
                                                                                                  • valueThe value to find the depth for
                                                                                                    (
                                                                                                    value: string,
                                                                                                    ) => number
                                                                                                    Gets all descendant nodes of the specified node.
                                                                                                    • valueOrIndexPathEither a node value or index path
                                                                                                    • optionsOptions for controlling which descendants to include
                                                                                                      (
                                                                                                      valueOrIndexPath?:
                                                                                                      | string
                                                                                                      | number[],
                                                                                                      options?: T & {
                                                                                                      disabled?: boolean
                                                                                                      id?: string
                                                                                                      onUnregister?: (
                                                                                                      index: number,
                                                                                                      ) => void
                                                                                                      requireContext?: boolean
                                                                                                      },
                                                                                                      ) => Array<T>
                                                                                                      Gets all descendant values of the specified node.
                                                                                                      • valueOrIndexPathEither a node value or index path
                                                                                                      • optionsOptions for controlling which descendants to include
                                                                                                        (
                                                                                                        valueOrIndexPath:
                                                                                                        | string
                                                                                                        | number[],
                                                                                                        options?: T & {
                                                                                                        disabled?: boolean
                                                                                                        id?: string
                                                                                                        onUnregister?: (
                                                                                                        index: number,
                                                                                                        ) => void
                                                                                                        requireContext?: boolean
                                                                                                        },
                                                                                                        ) => string[]
                                                                                                        Gets the first non-disabled node in the tree.
                                                                                                        • rootNodeThe root node to start searching from
                                                                                                          (
                                                                                                          rootNode?: T,
                                                                                                          ) => T
                                                                                                          Gets the index path for a node with the specified value.
                                                                                                          • valueThe value to find the index path for
                                                                                                            (
                                                                                                            value: string,
                                                                                                            ) => number[]
                                                                                                            Gets the last non-disabled node in the tree.
                                                                                                            • rootNodeThe root node to start searching from
                                                                                                            • optsOptions for skipping nodes during traversal
                                                                                                              (
                                                                                                              rootNode?: T,
                                                                                                              opts?: {
                                                                                                              skip?: (args: {
                                                                                                              indexPath: number[]
                                                                                                              node: T
                                                                                                              value: string
                                                                                                              }) => boolean | void
                                                                                                              },
                                                                                                              ) => T
                                                                                                              Gets the next node after the one with the specified value.
                                                                                                              • valueThe value to find the next node from
                                                                                                              • optsOptions for skipping nodes during traversal
                                                                                                                (
                                                                                                                value: string,
                                                                                                                opts?: {
                                                                                                                skip?: (args: {
                                                                                                                indexPath: number[]
                                                                                                                node: T
                                                                                                                value: string
                                                                                                                }) => boolean | void
                                                                                                                },
                                                                                                                ) => T
                                                                                                                Gets the next non-disabled sibling of the node at the index path.
                                                                                                                • indexPathArray of indices representing the path to the node
                                                                                                                  (
                                                                                                                  indexPath: number[],
                                                                                                                  ) => T
                                                                                                                  Returns all child nodes for this node. Uses options.nodeToChildren if provided, otherwise falls back to default behavior.
                                                                                                                      (
                                                                                                                      node: T,
                                                                                                                      ) => Array<T>
                                                                                                                      Gets the number of children for a node, supporting lazy loading scenarios. Uses options.nodeToChildrenCount if provided, otherwise falls back to default behavior.
                                                                                                                      • nodeThe node to get children count for
                                                                                                                        (
                                                                                                                        node: T,
                                                                                                                        ) => number
                                                                                                                        Checks if a node is disabled. Uses options.isNodeDisabled if provided, otherwise falls back to default behavior.
                                                                                                                        • nodeThe node to check
                                                                                                                          (
                                                                                                                          node: T,
                                                                                                                          ) => boolean
                                                                                                                          Gets the string value for a node. Uses options.nodeValue if provided, otherwise falls back to default behavior.
                                                                                                                          • nodeThe node to get the value from
                                                                                                                            (
                                                                                                                            node: T,
                                                                                                                            ) => string
                                                                                                                            Gets the parent node of the specified node.
                                                                                                                            • valueOrIndexPathEither a node value or index path
                                                                                                                              (
                                                                                                                              valueOrIndexPath:
                                                                                                                              | string
                                                                                                                              | number[],
                                                                                                                              ) => T
                                                                                                                              Gets all parent nodes from root to the specified node.
                                                                                                                              • valueOrIndexPathEither a node value or index path
                                                                                                                                (
                                                                                                                                valueOrIndexPath:
                                                                                                                                | string
                                                                                                                                | number[],
                                                                                                                                ) => Array<T>
                                                                                                                                Gets the previous node before the one with the specified value.
                                                                                                                                • valueThe value to find the previous node from
                                                                                                                                • optsOptions for skipping nodes during traversal
                                                                                                                                  (
                                                                                                                                  value: string,
                                                                                                                                  opts?: {
                                                                                                                                  skip?: (args: {
                                                                                                                                  indexPath: number[]
                                                                                                                                  node: T
                                                                                                                                  value: string
                                                                                                                                  }) => boolean | void
                                                                                                                                  },
                                                                                                                                  ) => T
                                                                                                                                  Gets the previous non-disabled sibling of the node at the index path.
                                                                                                                                  • indexPathArray of indices representing the path to the node
                                                                                                                                    (
                                                                                                                                    indexPath: number[],
                                                                                                                                    ) => T
                                                                                                                                    Gets all sibling nodes of the node at the index path.
                                                                                                                                    • indexPathArray of indices representing the path to the node
                                                                                                                                      (
                                                                                                                                      indexPath: number[],
                                                                                                                                      ) => Array<T>
                                                                                                                                      Gets the value of the node at the specified index path.
                                                                                                                                      • indexPathArray of indices representing the path to the node
                                                                                                                                        (
                                                                                                                                        indexPath: number[],
                                                                                                                                        ) => string
                                                                                                                                        Gets the path of values from root to the specified index path.
                                                                                                                                        • indexPathArray of indices representing the path to the node
                                                                                                                                          (
                                                                                                                                          indexPath: number[],
                                                                                                                                          ) => string[]
                                                                                                                                          Gets all values in the tree, excluding the root node.
                                                                                                                                          • rootNodeThe root node to start from
                                                                                                                                            (
                                                                                                                                            rootNode?: T,
                                                                                                                                            ) => string[]
                                                                                                                                            Groups children of a parent node by a specified key.
                                                                                                                                            • parentIndexPathIndex path of the parent node whose children to group. Pass [] for root-level children.
                                                                                                                                            • groupByFunction that determines the group key for each child node
                                                                                                                                            • sortGroupsOptional array of group keys defining order, or comparator function to sort the groups. By default, groups are sorted by first occurrence in the tree (insertion order)
                                                                                                                                              (
                                                                                                                                              parentIndexPath: IndexPath,
                                                                                                                                              groupBy: (
                                                                                                                                              node: T,
                                                                                                                                              index: number,
                                                                                                                                              ) => string,
                                                                                                                                              sortGroups?:
                                                                                                                                              | string[]
                                                                                                                                              | ((
                                                                                                                                              a: {
                                                                                                                                              items: Array<{
                                                                                                                                              indexPath: IndexPath
                                                                                                                                              node: T
                                                                                                                                              }>
                                                                                                                                              key: string
                                                                                                                                              },
                                                                                                                                              b: {
                                                                                                                                              items: Array<{
                                                                                                                                              indexPath: IndexPath
                                                                                                                                              node: T
                                                                                                                                              }>
                                                                                                                                              key: string
                                                                                                                                              },
                                                                                                                                              ) => number),
                                                                                                                                              ) => GroupedTreeNode<T>[]
                                                                                                                                              // Group root-level children
                                                                                                                                              const groups = collection.groupChildren([], (node) => node.group ?? 'default')

                                                                                                                                              // Group with explicit order
                                                                                                                                              const groups = collection.groupChildren(
                                                                                                                                              [],
                                                                                                                                              (node) => node.group,
                                                                                                                                              ['primary', 'secondary', 'tertiary']
                                                                                                                                              )

                                                                                                                                              // Group with custom sorter
                                                                                                                                              const groups = collection.groupChildren(
                                                                                                                                              [],
                                                                                                                                              (node) => node.group,
                                                                                                                                              (a, b) => String(a.key).localeCompare(String(b.key))
                                                                                                                                              )
                                                                                                                                              Inserts nodes after the node at the specified index path.
                                                                                                                                              • indexPathArray of indices representing the insertion point
                                                                                                                                              • nodesArray of nodes to insert
                                                                                                                                                (
                                                                                                                                                indexPath: number[],
                                                                                                                                                nodes: Array<T>,
                                                                                                                                                ) => any
                                                                                                                                                Inserts nodes before the node at the specified index path.
                                                                                                                                                • indexPathArray of indices representing the insertion point
                                                                                                                                                • nodesArray of nodes to insert
                                                                                                                                                  (
                                                                                                                                                  indexPath: number[],
                                                                                                                                                  nodes: Array<T>,
                                                                                                                                                  ) => any
                                                                                                                                                  Checks if a node is a branch node (has children or can have children).
                                                                                                                                                  • nodeThe node to check
                                                                                                                                                    (
                                                                                                                                                    node: T,
                                                                                                                                                    ) => boolean
                                                                                                                                                    Compares this tree collection with another for deep equality.
                                                                                                                                                    • otherThe other tree collection to compare with
                                                                                                                                                      (
                                                                                                                                                      other: TreeCollection<T>,
                                                                                                                                                      ) => boolean
                                                                                                                                                      Checks if a node is the root node.
                                                                                                                                                      • nodeThe node to check
                                                                                                                                                        (
                                                                                                                                                        node: T,
                                                                                                                                                        ) => boolean
                                                                                                                                                        Checks if two nodes are the same by comparing their values.
                                                                                                                                                        • nodeFirst node to compare
                                                                                                                                                        • otherSecond node to compare
                                                                                                                                                          (
                                                                                                                                                          node: T,
                                                                                                                                                          other: T,
                                                                                                                                                          ) => boolean
                                                                                                                                                          Moves nodes from one location to another in the tree.
                                                                                                                                                          • fromIndexPathsArray of index paths to move from
                                                                                                                                                          • toIndexPathIndex path to move to
                                                                                                                                                            (
                                                                                                                                                            fromIndexPaths: Array<
                                                                                                                                                            number[]
                                                                                                                                                            >,
                                                                                                                                                            toIndexPath: number[],
                                                                                                                                                            ) => any
                                                                                                                                                            Removes nodes at the specified index paths.
                                                                                                                                                            • indexPathsArray of index paths to remove
                                                                                                                                                              (
                                                                                                                                                              indexPaths: Array<number[]>,
                                                                                                                                                              ) => any
                                                                                                                                                              Replaces the node at the specified index path.
                                                                                                                                                              • indexPathArray of indices representing the path to the node
                                                                                                                                                              • nodeThe new node to replace with
                                                                                                                                                                (
                                                                                                                                                                indexPath: number[],
                                                                                                                                                                node: T,
                                                                                                                                                                ) => any
                                                                                                                                                                The root tree node.
                                                                                                                                                                T
                                                                                                                                                                Sorts values according to their tree order.
                                                                                                                                                                • valuesArray of values to sort
                                                                                                                                                                  (
                                                                                                                                                                  values: string[],
                                                                                                                                                                  ) => string[]
                                                                                                                                                                  Converts a node value to its string representation.
                                                                                                                                                                  • valueThe value to stringify
                                                                                                                                                                  (
                                                                                                                                                                  value: string,
                                                                                                                                                                  ) => string
                                                                                                                                                                  Converts a node to its string representation. Uses options.nodeLabel if provided, otherwise falls back to default behavior: uses node.text, or node.value if node.text is not available.
                                                                                                                                                                  • nodeThe node to stringify
                                                                                                                                                                  (
                                                                                                                                                                  T,
                                                                                                                                                                  ) => string
                                                                                                                                                                  Serializes the tree to a JSON-compatible array of values.
                                                                                                                                                                      () => string[]
                                                                                                                                                                      Visits all nodes in the tree with optional skip functionality.
                                                                                                                                                                      • optsOptions for visiting nodes, including skip predicate
                                                                                                                                                                        (opts: {
                                                                                                                                                                        onEnter?: (
                                                                                                                                                                        node: T,
                                                                                                                                                                        indexPath: number[],
                                                                                                                                                                        ) => void | 'skip' | 'stop'
                                                                                                                                                                        onLeave?: (
                                                                                                                                                                        node: T,
                                                                                                                                                                        indexPath: number[],
                                                                                                                                                                        ) => void | 'stop'
                                                                                                                                                                        reuseIndexPath?: boolean
                                                                                                                                                                        skip?: (args: {
                                                                                                                                                                        indexPath: number[]
                                                                                                                                                                        node: T
                                                                                                                                                                        value: string
                                                                                                                                                                        }) => boolean | void
                                                                                                                                                                        }) => void
                                                                                                                                                                        Type
                                                                                                                                                                        (
                                                                                                                                                                        indexPath: number[],
                                                                                                                                                                        ) => T
                                                                                                                                                                        Description
                                                                                                                                                                        Gets the node at the specified index path.
                                                                                                                                                                        • indexPathArray of indices representing the path to the node
                                                                                                                                                                          Type
                                                                                                                                                                          (
                                                                                                                                                                          parentIndexPath: number[],
                                                                                                                                                                          valueIndexPath: number[],
                                                                                                                                                                          ) => boolean
                                                                                                                                                                          Description
                                                                                                                                                                          Checks if a parent index path contains a child index path.
                                                                                                                                                                          • parentIndexPathThe parent path
                                                                                                                                                                          • valueIndexPathThe child path to check
                                                                                                                                                                            Type
                                                                                                                                                                            (
                                                                                                                                                                            rootNode: T,
                                                                                                                                                                            ) => any
                                                                                                                                                                            Description
                                                                                                                                                                            Creates a new tree collection with the same options but different root node.
                                                                                                                                                                            • rootNodeThe new root node for the copied collection
                                                                                                                                                                              Type
                                                                                                                                                                              (
                                                                                                                                                                              predicate: (
                                                                                                                                                                              node: T,
                                                                                                                                                                              indexPath: number[],
                                                                                                                                                                              ) => boolean,
                                                                                                                                                                              ) => any
                                                                                                                                                                              Description
                                                                                                                                                                              Filters the tree keeping only nodes that match the predicate.
                                                                                                                                                                              • predicateFunction to test each node
                                                                                                                                                                                Type
                                                                                                                                                                                (
                                                                                                                                                                                value: string,
                                                                                                                                                                                rootNode?: T,
                                                                                                                                                                                ) => T
                                                                                                                                                                                Description
                                                                                                                                                                                Finds the first node with the specified value.
                                                                                                                                                                                • valueThe value to search for
                                                                                                                                                                                • rootNodeThe root node to start searching from
                                                                                                                                                                                  Type
                                                                                                                                                                                  (
                                                                                                                                                                                  predicate: (
                                                                                                                                                                                  node: T,
                                                                                                                                                                                  indexPath: number[],
                                                                                                                                                                                  ) => boolean,
                                                                                                                                                                                  rootNode?: T,
                                                                                                                                                                                  ) => T
                                                                                                                                                                                  Type
                                                                                                                                                                                  (
                                                                                                                                                                                  values: string[],
                                                                                                                                                                                  rootNode?: T,
                                                                                                                                                                                  ) => Array<T>
                                                                                                                                                                                  Description
                                                                                                                                                                                  Finds all nodes with values matching the provided array.
                                                                                                                                                                                  • valuesArray of values to search for
                                                                                                                                                                                  • rootNodeThe root node to start searching from
                                                                                                                                                                                    Type
                                                                                                                                                                                    (
                                                                                                                                                                                    rootNode?: T,
                                                                                                                                                                                    ) => Array<
                                                                                                                                                                                    T & {
                                                                                                                                                                                    _children: number[]
                                                                                                                                                                                    _index: number
                                                                                                                                                                                    _parent: number
                                                                                                                                                                                    }
                                                                                                                                                                                    >
                                                                                                                                                                                    Description
                                                                                                                                                                                    Flattens the tree into an array with parent/child relationships.
                                                                                                                                                                                    • rootNodeThe root node to start flattening from
                                                                                                                                                                                      Type
                                                                                                                                                                                      (
                                                                                                                                                                                      rootNode?: T,
                                                                                                                                                                                      opts?: {
                                                                                                                                                                                      skip?: (args: {
                                                                                                                                                                                      indexPath: number[]
                                                                                                                                                                                      node: T
                                                                                                                                                                                      value: string
                                                                                                                                                                                      }) => boolean | void
                                                                                                                                                                                      } & {
                                                                                                                                                                                      depth?:
                                                                                                                                                                                      | number
                                                                                                                                                                                      | ((
                                                                                                                                                                                      nodeDepth: number,
                                                                                                                                                                                      ) => boolean)
                                                                                                                                                                                      },
                                                                                                                                                                                      ) => string[]
                                                                                                                                                                                      Description
                                                                                                                                                                                      Gets all branch node values with optional depth filtering.
                                                                                                                                                                                      • rootNodeThe root node to start from
                                                                                                                                                                                      • optsOptions for skipping nodes and filtering by depth
                                                                                                                                                                                        Type
                                                                                                                                                                                        (
                                                                                                                                                                                        value: string,
                                                                                                                                                                                        ) => number
                                                                                                                                                                                        Description
                                                                                                                                                                                        Gets the depth of a node with the specified value.
                                                                                                                                                                                        • valueThe value to find the depth for
                                                                                                                                                                                          Type
                                                                                                                                                                                          (
                                                                                                                                                                                          valueOrIndexPath?:
                                                                                                                                                                                          | string
                                                                                                                                                                                          | number[],
                                                                                                                                                                                          options?: T & {
                                                                                                                                                                                          disabled?: boolean
                                                                                                                                                                                          id?: string
                                                                                                                                                                                          onUnregister?: (
                                                                                                                                                                                          index: number,
                                                                                                                                                                                          ) => void
                                                                                                                                                                                          requireContext?: boolean
                                                                                                                                                                                          },
                                                                                                                                                                                          ) => Array<T>
                                                                                                                                                                                          Description
                                                                                                                                                                                          Gets all descendant nodes of the specified node.
                                                                                                                                                                                          • valueOrIndexPathEither a node value or index path
                                                                                                                                                                                          • optionsOptions for controlling which descendants to include
                                                                                                                                                                                            Type
                                                                                                                                                                                            (
                                                                                                                                                                                            valueOrIndexPath:
                                                                                                                                                                                            | string
                                                                                                                                                                                            | number[],
                                                                                                                                                                                            options?: T & {
                                                                                                                                                                                            disabled?: boolean
                                                                                                                                                                                            id?: string
                                                                                                                                                                                            onUnregister?: (
                                                                                                                                                                                            index: number,
                                                                                                                                                                                            ) => void
                                                                                                                                                                                            requireContext?: boolean
                                                                                                                                                                                            },
                                                                                                                                                                                            ) => string[]
                                                                                                                                                                                            Description
                                                                                                                                                                                            Gets all descendant values of the specified node.
                                                                                                                                                                                            • valueOrIndexPathEither a node value or index path
                                                                                                                                                                                            • optionsOptions for controlling which descendants to include
                                                                                                                                                                                              Type
                                                                                                                                                                                              (
                                                                                                                                                                                              rootNode?: T,
                                                                                                                                                                                              ) => T
                                                                                                                                                                                              Description
                                                                                                                                                                                              Gets the first non-disabled node in the tree.
                                                                                                                                                                                              • rootNodeThe root node to start searching from
                                                                                                                                                                                                Type
                                                                                                                                                                                                (
                                                                                                                                                                                                value: string,
                                                                                                                                                                                                ) => number[]
                                                                                                                                                                                                Description
                                                                                                                                                                                                Gets the index path for a node with the specified value.
                                                                                                                                                                                                • valueThe value to find the index path for
                                                                                                                                                                                                  Type
                                                                                                                                                                                                  (
                                                                                                                                                                                                  rootNode?: T,
                                                                                                                                                                                                  opts?: {
                                                                                                                                                                                                  skip?: (args: {
                                                                                                                                                                                                  indexPath: number[]
                                                                                                                                                                                                  node: T
                                                                                                                                                                                                  value: string
                                                                                                                                                                                                  }) => boolean | void
                                                                                                                                                                                                  },
                                                                                                                                                                                                  ) => T
                                                                                                                                                                                                  Description
                                                                                                                                                                                                  Gets the last non-disabled node in the tree.
                                                                                                                                                                                                  • rootNodeThe root node to start searching from
                                                                                                                                                                                                  • optsOptions for skipping nodes during traversal
                                                                                                                                                                                                    Type
                                                                                                                                                                                                    (
                                                                                                                                                                                                    value: string,
                                                                                                                                                                                                    opts?: {
                                                                                                                                                                                                    skip?: (args: {
                                                                                                                                                                                                    indexPath: number[]
                                                                                                                                                                                                    node: T
                                                                                                                                                                                                    value: string
                                                                                                                                                                                                    }) => boolean | void
                                                                                                                                                                                                    },
                                                                                                                                                                                                    ) => T
                                                                                                                                                                                                    Description
                                                                                                                                                                                                    Gets the next node after the one with the specified value.
                                                                                                                                                                                                    • valueThe value to find the next node from
                                                                                                                                                                                                    • optsOptions for skipping nodes during traversal
                                                                                                                                                                                                      Type
                                                                                                                                                                                                      (
                                                                                                                                                                                                      indexPath: number[],
                                                                                                                                                                                                      ) => T
                                                                                                                                                                                                      Description
                                                                                                                                                                                                      Gets the next non-disabled sibling of the node at the index path.
                                                                                                                                                                                                      • indexPathArray of indices representing the path to the node
                                                                                                                                                                                                        Type
                                                                                                                                                                                                        (
                                                                                                                                                                                                        node: T,
                                                                                                                                                                                                        ) => Array<T>
                                                                                                                                                                                                        Description
                                                                                                                                                                                                        Returns all child nodes for this node. Uses options.nodeToChildren if provided, otherwise falls back to default behavior.
                                                                                                                                                                                                            Type
                                                                                                                                                                                                            (
                                                                                                                                                                                                            node: T,
                                                                                                                                                                                                            ) => number
                                                                                                                                                                                                            Description
                                                                                                                                                                                                            Gets the number of children for a node, supporting lazy loading scenarios. Uses options.nodeToChildrenCount if provided, otherwise falls back to default behavior.
                                                                                                                                                                                                            • nodeThe node to get children count for
                                                                                                                                                                                                              Type
                                                                                                                                                                                                              (
                                                                                                                                                                                                              node: T,
                                                                                                                                                                                                              ) => boolean
                                                                                                                                                                                                              Description
                                                                                                                                                                                                              Checks if a node is disabled. Uses options.isNodeDisabled if provided, otherwise falls back to default behavior.
                                                                                                                                                                                                              • nodeThe node to check
                                                                                                                                                                                                                Type
                                                                                                                                                                                                                (
                                                                                                                                                                                                                node: T,
                                                                                                                                                                                                                ) => string
                                                                                                                                                                                                                Description
                                                                                                                                                                                                                Gets the string value for a node. Uses options.nodeValue if provided, otherwise falls back to default behavior.
                                                                                                                                                                                                                • nodeThe node to get the value from
                                                                                                                                                                                                                  Type
                                                                                                                                                                                                                  (
                                                                                                                                                                                                                  valueOrIndexPath:
                                                                                                                                                                                                                  | string
                                                                                                                                                                                                                  | number[],
                                                                                                                                                                                                                  ) => T
                                                                                                                                                                                                                  Description
                                                                                                                                                                                                                  Gets the parent node of the specified node.
                                                                                                                                                                                                                  • valueOrIndexPathEither a node value or index path
                                                                                                                                                                                                                    Type
                                                                                                                                                                                                                    (
                                                                                                                                                                                                                    valueOrIndexPath:
                                                                                                                                                                                                                    | string
                                                                                                                                                                                                                    | number[],
                                                                                                                                                                                                                    ) => Array<T>
                                                                                                                                                                                                                    Description
                                                                                                                                                                                                                    Gets all parent nodes from root to the specified node.
                                                                                                                                                                                                                    • valueOrIndexPathEither a node value or index path
                                                                                                                                                                                                                      Type
                                                                                                                                                                                                                      (
                                                                                                                                                                                                                      value: string,
                                                                                                                                                                                                                      opts?: {
                                                                                                                                                                                                                      skip?: (args: {
                                                                                                                                                                                                                      indexPath: number[]
                                                                                                                                                                                                                      node: T
                                                                                                                                                                                                                      value: string
                                                                                                                                                                                                                      }) => boolean | void
                                                                                                                                                                                                                      },
                                                                                                                                                                                                                      ) => T
                                                                                                                                                                                                                      Description
                                                                                                                                                                                                                      Gets the previous node before the one with the specified value.
                                                                                                                                                                                                                      • valueThe value to find the previous node from
                                                                                                                                                                                                                      • optsOptions for skipping nodes during traversal
                                                                                                                                                                                                                        Type
                                                                                                                                                                                                                        (
                                                                                                                                                                                                                        indexPath: number[],
                                                                                                                                                                                                                        ) => T
                                                                                                                                                                                                                        Description
                                                                                                                                                                                                                        Gets the previous non-disabled sibling of the node at the index path.
                                                                                                                                                                                                                        • indexPathArray of indices representing the path to the node
                                                                                                                                                                                                                          Type
                                                                                                                                                                                                                          (
                                                                                                                                                                                                                          indexPath: number[],
                                                                                                                                                                                                                          ) => Array<T>
                                                                                                                                                                                                                          Description
                                                                                                                                                                                                                          Gets all sibling nodes of the node at the index path.
                                                                                                                                                                                                                          • indexPathArray of indices representing the path to the node
                                                                                                                                                                                                                            Type
                                                                                                                                                                                                                            (
                                                                                                                                                                                                                            indexPath: number[],
                                                                                                                                                                                                                            ) => string
                                                                                                                                                                                                                            Description
                                                                                                                                                                                                                            Gets the value of the node at the specified index path.
                                                                                                                                                                                                                            • indexPathArray of indices representing the path to the node
                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                              (
                                                                                                                                                                                                                              indexPath: number[],
                                                                                                                                                                                                                              ) => string[]
                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                              Gets the path of values from root to the specified index path.
                                                                                                                                                                                                                              • indexPathArray of indices representing the path to the node
                                                                                                                                                                                                                                Type
                                                                                                                                                                                                                                (
                                                                                                                                                                                                                                rootNode?: T,
                                                                                                                                                                                                                                ) => string[]
                                                                                                                                                                                                                                Description
                                                                                                                                                                                                                                Gets all values in the tree, excluding the root node.
                                                                                                                                                                                                                                • rootNodeThe root node to start from
                                                                                                                                                                                                                                  Type
                                                                                                                                                                                                                                  (
                                                                                                                                                                                                                                  parentIndexPath: IndexPath,
                                                                                                                                                                                                                                  groupBy: (
                                                                                                                                                                                                                                  node: T,
                                                                                                                                                                                                                                  index: number,
                                                                                                                                                                                                                                  ) => string,
                                                                                                                                                                                                                                  sortGroups?:
                                                                                                                                                                                                                                  | string[]
                                                                                                                                                                                                                                  | ((
                                                                                                                                                                                                                                  a: {
                                                                                                                                                                                                                                  items: Array<{
                                                                                                                                                                                                                                  indexPath: IndexPath
                                                                                                                                                                                                                                  node: T
                                                                                                                                                                                                                                  }>
                                                                                                                                                                                                                                  key: string
                                                                                                                                                                                                                                  },
                                                                                                                                                                                                                                  b: {
                                                                                                                                                                                                                                  items: Array<{
                                                                                                                                                                                                                                  indexPath: IndexPath
                                                                                                                                                                                                                                  node: T
                                                                                                                                                                                                                                  }>
                                                                                                                                                                                                                                  key: string
                                                                                                                                                                                                                                  },
                                                                                                                                                                                                                                  ) => number),
                                                                                                                                                                                                                                  ) => GroupedTreeNode<T>[]
                                                                                                                                                                                                                                  Description
                                                                                                                                                                                                                                  Groups children of a parent node by a specified key.
                                                                                                                                                                                                                                  • parentIndexPathIndex path of the parent node whose children to group. Pass [] for root-level children.
                                                                                                                                                                                                                                  • groupByFunction that determines the group key for each child node
                                                                                                                                                                                                                                  • sortGroupsOptional array of group keys defining order, or comparator function to sort the groups. By default, groups are sorted by first occurrence in the tree (insertion order)
                                                                                                                                                                                                                                    // Group root-level children
                                                                                                                                                                                                                                    const groups = collection.groupChildren([], (node) => node.group ?? 'default')

                                                                                                                                                                                                                                    // Group with explicit order
                                                                                                                                                                                                                                    const groups = collection.groupChildren(
                                                                                                                                                                                                                                    [],
                                                                                                                                                                                                                                    (node) => node.group,
                                                                                                                                                                                                                                    ['primary', 'secondary', 'tertiary']
                                                                                                                                                                                                                                    )

                                                                                                                                                                                                                                    // Group with custom sorter
                                                                                                                                                                                                                                    const groups = collection.groupChildren(
                                                                                                                                                                                                                                    [],
                                                                                                                                                                                                                                    (node) => node.group,
                                                                                                                                                                                                                                    (a, b) => String(a.key).localeCompare(String(b.key))
                                                                                                                                                                                                                                    )
                                                                                                                                                                                                                                    Type
                                                                                                                                                                                                                                    (
                                                                                                                                                                                                                                    indexPath: number[],
                                                                                                                                                                                                                                    nodes: Array<T>,
                                                                                                                                                                                                                                    ) => any
                                                                                                                                                                                                                                    Description
                                                                                                                                                                                                                                    Inserts nodes after the node at the specified index path.
                                                                                                                                                                                                                                    • indexPathArray of indices representing the insertion point
                                                                                                                                                                                                                                    • nodesArray of nodes to insert
                                                                                                                                                                                                                                      Type
                                                                                                                                                                                                                                      (
                                                                                                                                                                                                                                      indexPath: number[],
                                                                                                                                                                                                                                      nodes: Array<T>,
                                                                                                                                                                                                                                      ) => any
                                                                                                                                                                                                                                      Description
                                                                                                                                                                                                                                      Inserts nodes before the node at the specified index path.
                                                                                                                                                                                                                                      • indexPathArray of indices representing the insertion point
                                                                                                                                                                                                                                      • nodesArray of nodes to insert
                                                                                                                                                                                                                                        Type
                                                                                                                                                                                                                                        (
                                                                                                                                                                                                                                        node: T,
                                                                                                                                                                                                                                        ) => boolean
                                                                                                                                                                                                                                        Description
                                                                                                                                                                                                                                        Checks if a node is a branch node (has children or can have children).
                                                                                                                                                                                                                                        • nodeThe node to check
                                                                                                                                                                                                                                          Type
                                                                                                                                                                                                                                          (
                                                                                                                                                                                                                                          other: TreeCollection<T>,
                                                                                                                                                                                                                                          ) => boolean
                                                                                                                                                                                                                                          Description
                                                                                                                                                                                                                                          Compares this tree collection with another for deep equality.
                                                                                                                                                                                                                                          • otherThe other tree collection to compare with
                                                                                                                                                                                                                                            Type
                                                                                                                                                                                                                                            (
                                                                                                                                                                                                                                            node: T,
                                                                                                                                                                                                                                            ) => boolean
                                                                                                                                                                                                                                            Description
                                                                                                                                                                                                                                            Checks if a node is the root node.
                                                                                                                                                                                                                                            • nodeThe node to check
                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                              (
                                                                                                                                                                                                                                              node: T,
                                                                                                                                                                                                                                              other: T,
                                                                                                                                                                                                                                              ) => boolean
                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                              Checks if two nodes are the same by comparing their values.
                                                                                                                                                                                                                                              • nodeFirst node to compare
                                                                                                                                                                                                                                              • otherSecond node to compare
                                                                                                                                                                                                                                                Type
                                                                                                                                                                                                                                                (
                                                                                                                                                                                                                                                fromIndexPaths: Array<
                                                                                                                                                                                                                                                number[]
                                                                                                                                                                                                                                                >,
                                                                                                                                                                                                                                                toIndexPath: number[],
                                                                                                                                                                                                                                                ) => any
                                                                                                                                                                                                                                                Description
                                                                                                                                                                                                                                                Moves nodes from one location to another in the tree.
                                                                                                                                                                                                                                                • fromIndexPathsArray of index paths to move from
                                                                                                                                                                                                                                                • toIndexPathIndex path to move to
                                                                                                                                                                                                                                                  Type
                                                                                                                                                                                                                                                  (
                                                                                                                                                                                                                                                  indexPaths: Array<number[]>,
                                                                                                                                                                                                                                                  ) => any
                                                                                                                                                                                                                                                  Description
                                                                                                                                                                                                                                                  Removes nodes at the specified index paths.
                                                                                                                                                                                                                                                  • indexPathsArray of index paths to remove
                                                                                                                                                                                                                                                    Type
                                                                                                                                                                                                                                                    (
                                                                                                                                                                                                                                                    indexPath: number[],
                                                                                                                                                                                                                                                    node: T,
                                                                                                                                                                                                                                                    ) => any
                                                                                                                                                                                                                                                    Description
                                                                                                                                                                                                                                                    Replaces the node at the specified index path.
                                                                                                                                                                                                                                                    • indexPathArray of indices representing the path to the node
                                                                                                                                                                                                                                                    • nodeThe new node to replace with
                                                                                                                                                                                                                                                      Type
                                                                                                                                                                                                                                                      T
                                                                                                                                                                                                                                                      Description
                                                                                                                                                                                                                                                      The root tree node.
                                                                                                                                                                                                                                                      Type
                                                                                                                                                                                                                                                      (
                                                                                                                                                                                                                                                      values: string[],
                                                                                                                                                                                                                                                      ) => string[]
                                                                                                                                                                                                                                                      Description
                                                                                                                                                                                                                                                      Sorts values according to their tree order.
                                                                                                                                                                                                                                                      • valuesArray of values to sort
                                                                                                                                                                                                                                                        Type
                                                                                                                                                                                                                                                        (
                                                                                                                                                                                                                                                        value: string,
                                                                                                                                                                                                                                                        ) => string
                                                                                                                                                                                                                                                        Description
                                                                                                                                                                                                                                                        Converts a node value to its string representation.
                                                                                                                                                                                                                                                        • valueThe value to stringify
                                                                                                                                                                                                                                                        Type
                                                                                                                                                                                                                                                        (
                                                                                                                                                                                                                                                        T,
                                                                                                                                                                                                                                                        ) => string
                                                                                                                                                                                                                                                        Description
                                                                                                                                                                                                                                                        Converts a node to its string representation. Uses options.nodeLabel if provided, otherwise falls back to default behavior: uses node.text, or node.value if node.text is not available.
                                                                                                                                                                                                                                                        • nodeThe node to stringify
                                                                                                                                                                                                                                                        Type
                                                                                                                                                                                                                                                        () => string[]
                                                                                                                                                                                                                                                        Description
                                                                                                                                                                                                                                                        Serializes the tree to a JSON-compatible array of values.
                                                                                                                                                                                                                                                            Type
                                                                                                                                                                                                                                                            (opts: {
                                                                                                                                                                                                                                                            onEnter?: (
                                                                                                                                                                                                                                                            node: T,
                                                                                                                                                                                                                                                            indexPath: number[],
                                                                                                                                                                                                                                                            ) => void | 'skip' | 'stop'
                                                                                                                                                                                                                                                            onLeave?: (
                                                                                                                                                                                                                                                            node: T,
                                                                                                                                                                                                                                                            indexPath: number[],
                                                                                                                                                                                                                                                            ) => void | 'stop'
                                                                                                                                                                                                                                                            reuseIndexPath?: boolean
                                                                                                                                                                                                                                                            skip?: (args: {
                                                                                                                                                                                                                                                            indexPath: number[]
                                                                                                                                                                                                                                                            node: T
                                                                                                                                                                                                                                                            value: string
                                                                                                                                                                                                                                                            }) => boolean | void
                                                                                                                                                                                                                                                            }) => void
                                                                                                                                                                                                                                                            Description
                                                                                                                                                                                                                                                            Visits all nodes in the tree with optional skip functionality.
                                                                                                                                                                                                                                                            • optsOptions for visiting nodes, including skip predicate

                                                                                                                                                                                                                                                              Element API

                                                                                                                                                                                                                                                              <Tree.Label>

                                                                                                                                                                                                                                                              An optional accessible label for the tree. Renders a <div> element by default.
                                                                                                                                                                                                                                                              PropType
                                                                                                                                                                                                                                                              id attribute. If omitted, a unique identifier will be automatically generated for accessibility.
                                                                                                                                                                                                                                                              string
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              string
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              id attribute. If omitted, a unique identifier will be automatically generated for accessibility.
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more

                                                                                                                                                                                                                                                              <Tree.Branch>

                                                                                                                                                                                                                                                              Groups the branch node and its content element. Renders a <div> element by default.
                                                                                                                                                                                                                                                              PropType
                                                                                                                                                                                                                                                              React children prop.
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              React children prop.
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more

                                                                                                                                                                                                                                                              <Tree.BranchNode>

                                                                                                                                                                                                                                                              An interactive tree item with children. Renders a <div> element by default.
                                                                                                                                                                                                                                                              PropType
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more

                                                                                                                                                                                                                                                              <Tree.BranchTrigger>

                                                                                                                                                                                                                                                              Action that indicates whether a branch is expanded or collapsed. Renders a <div> element by default.
                                                                                                                                                                                                                                                              PropTypeDefault
                                                                                                                                                                                                                                                              | LucideIcon
                                                                                                                                                                                                                                                              | ReactNode
                                                                                                                                                                                                                                                              ChevronRight
                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | LucideIcon
                                                                                                                                                                                                                                                              | ReactNode
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more

                                                                                                                                                                                                                                                              <Tree.BranchContent>

                                                                                                                                                                                                                                                              Container element for the branch node's children. Renders a <div> element by default.
                                                                                                                                                                                                                                                              PropType
                                                                                                                                                                                                                                                              React children prop.
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              React children prop.
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more

                                                                                                                                                                                                                                                              <Tree.BranchIndentGuide>

                                                                                                                                                                                                                                                              Provides a visual guide to the indentation level of the branch's children. Renders a <div> element by default.
                                                                                                                                                                                                                                                              PropType
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more

                                                                                                                                                                                                                                                              <Tree.LeafNode>

                                                                                                                                                                                                                                                              A childless tree item. Renders a <div> element by default.
                                                                                                                                                                                                                                                              PropType
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more

                                                                                                                                                                                                                                                              <Tree.NodeCheckbox>

                                                                                                                                                                                                                                                              A checkbox control within a tree item. Renders a <span> element by default.
                                                                                                                                                                                                                                                              PropTypeDefault
                                                                                                                                                                                                                                                              React Node rendered when the node is checked.
                                                                                                                                                                                                                                                              CheckmarkCheckedIcon
                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                              React Node rendered when the node is indeterminate.
                                                                                                                                                                                                                                                              CheckmarkIndeterminateIcon
                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              React Node rendered when the node is unchecked.
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              React Node rendered when the node is checked.
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              React Node rendered when the node is indeterminate.
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              React Node rendered when the node is unchecked.

                                                                                                                                                                                                                                                              <Tree.NodeAction>

                                                                                                                                                                                                                                                              An action button within a tree item's interactive area. Renders a <button> element by default.
                                                                                                                                                                                                                                                              PropTypeDefault
                                                                                                                                                                                                                                                              Lucide icon to display inside the button.
                                                                                                                                                                                                                                                              | LucideIcon
                                                                                                                                                                                                                                                              | ReactNode
                                                                                                                                                                                                                                                              The style variant of the button. Governs color. TODO: link to design system docs.
                                                                                                                                                                                                                                                              | 'neutral'
                                                                                                                                                                                                                                                              | 'persistent-white'
                                                                                                                                                                                                                                                              | 'persistent-black'
                                                                                                                                                                                                                                                              'neutral'
                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              The size of the button and its icon.
                                                                                                                                                                                                                                                              | 'sm'
                                                                                                                                                                                                                                                              | 'md'
                                                                                                                                                                                                                                                              | 'lg'
                                                                                                                                                                                                                                                              'md'
                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | LucideIcon
                                                                                                                                                                                                                                                              | ReactNode
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              Lucide icon to display inside the button.
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | 'neutral'
                                                                                                                                                                                                                                                              | 'persistent-white'
                                                                                                                                                                                                                                                              | 'persistent-black'
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              The style variant of the button. Governs color. TODO: link to design system docs.
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | 'sm'
                                                                                                                                                                                                                                                              | 'md'
                                                                                                                                                                                                                                                              | 'lg'
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              The size of the button and its icon.

                                                                                                                                                                                                                                                              <Tree.NodeIndicator>

                                                                                                                                                                                                                                                              Indicates whether the tree item is selected. Renders a <div> element by default.
                                                                                                                                                                                                                                                              PropType
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more

                                                                                                                                                                                                                                                              <Tree.NodeIcon>

                                                                                                                                                                                                                                                              The icon for the tree item. Renders a <span> element by default.
                                                                                                                                                                                                                                                              PropType
                                                                                                                                                                                                                                                              lucide-react icon or JSX Element.
                                                                                                                                                                                                                                                              | LucideIcon
                                                                                                                                                                                                                                                              | ReactNode
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | LucideIcon
                                                                                                                                                                                                                                                              | ReactNode
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              lucide-react icon or JSX Element.
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more

                                                                                                                                                                                                                                                              <Tree.NodeProvider>

                                                                                                                                                                                                                                                              PropType
                                                                                                                                                                                                                                                              The index path of the tree node
                                                                                                                                                                                                                                                              number[]
                                                                                                                                                                                                                                                              The tree node to apply context from.
                                                                                                                                                                                                                                                              T
                                                                                                                                                                                                                                                              React children prop.
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              number[]
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              The index path of the tree node
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              T
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              The tree node to apply context from.
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              React children prop.

                                                                                                                                                                                                                                                              <Tree.NodeText>

                                                                                                                                                                                                                                                              The primary title of the tree item. Renders a <span> element by default.
                                                                                                                                                                                                                                                              PropType
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Type
                                                                                                                                                                                                                                                              | ReactElement
                                                                                                                                                                                                                                                              | ((
                                                                                                                                                                                                                                                              props: object,
                                                                                                                                                                                                                                                              ) => ReactElement)
                                                                                                                                                                                                                                                              Description
                                                                                                                                                                                                                                                              Allows you to replace the component's HTML element with a different tag or component. Learn more