Introducing PrimeReact v11-alpha 🎉Discover Now

Tree

Unstyled, accessible tree primitive with a compound API.

Unstyled compound primitive for rendering hierarchical data with full control over markup.

    basic-demo

    Pre-styled Versions

    Choose a pre-styled library to use Tree with ready-made designs.
    For hook-based usage without components, see the Headless API.

    Features#

    • Compound parts: Root, Nodes, Node, Content, Toggle, ToggleIndicator, Selection, DropIndicator, Label, Filter, Header, Footer, Empty, Loading
    • Flat DOM with a single <ul role="tree"> containing one <li role="treeitem"> per visible row
    • Selection modes single, multiple and checkbox with tri-state cascade
    • Drag-and-drop with a single onMove event; validateMove can be sync or async

    Usage#

    import { Tree } from 'primereact/tree';
    <Tree.Root value={nodes}>
        <Tree.Header>
            <Tree.Filter />
        </Tree.Header>
        <Tree.Nodes>
            {({ node }) => (
                <Tree.Node uKey={node.key}>
                    <Tree.Content>
                        <Tree.Toggle>
                            <Tree.ToggleIndicator match="expanded">â–¼</Tree.ToggleIndicator>
                            <Tree.ToggleIndicator match="collapsed">â–¶</Tree.ToggleIndicator>
                        </Tree.Toggle>
                        <Tree.Label>{node.label}</Tree.Label>
                    </Tree.Content>
                </Tree.Node>
            )}
        </Tree.Nodes>
        <Tree.Footer />
        <Tree.Empty />
    </Tree.Root>

    Behavior#

    Flat Render#

    Tree.Nodes walks the data top-down and calls its render function once per visible row. Tree.Node looks the data up by uKey. Each <li> carries its depth in the --px-tree-node-level CSS variable (1-based); combine it with your own indent unit for indentation:

    [data-part='content'] {
        margin-inline-start: calc((var(--px-tree-node-level, 1) - 1) * var(--p-tree-indent, 1rem));
    }

    Toggle Indicator#

    Tree.Toggle renders no icon on its own. Add Tree.ToggleIndicator with match="expanded", match="collapsed" or match="always" inside to render per-state content. For leaf rows the toggle is replaced by <span data-part="toggle-spacer"> so the indentation stays aligned.

    Selection#

    Tree.Selection is render-prop based. Inside Tree.Node it exposes isSelected, isPartiallySelected and toggle. Inside Tree.Header it exposes isAllSelected, isSomeSelected and toggleAll. Pass mode="radio" | "checkbox" | "single" to force a specific toggle behavior.

    Polymorphism#

    Every sub-component takes an as prop. Pass another element or component to swap the rendered tag.

    Defaults: Root=div, Nodes=ul, Node=li, Content=div, Toggle=button, ToggleIndicator=span, Selection=Fragment, DropIndicator=div, Label=span, Filter=input, Header=div, Footer=div, Empty=div, Loading=div.

    Pass Through#

    Some parts may not be visible in the preview depending on the component's current state.

    Loading...
    /* Select a part to see its CSS selector for custom styling */

    API#

    TreeRoot#

    NameTypeDefault
    refRef<unknown>—
    The reference to the component instance.
    pIfbooleantrue
    Whether the component should be rendered.
    styleCSSProperties | ((instance?: TreeRootInstance) => CSSProperties)—
    The style to apply to the component.
    classNamestring | ((instance?: TreeRootInstance) => string)—
    The class name to apply to the component.
    asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
    The component type to render.
    asChildbooleanfalse
    Whether the component should be rendered as a child component.
    instanceTreeRootInstance—
    The instance to pass to the component.
    ptSafeRecord<TreeRootPassThrough>—
    The pass-through props to pass to the component.
    ptOptionsPassThroughOptions—
    The pass-through options to pass to the component.
    unstyledboolean—
    Whether the component should be rendered without classes.
    dtunknown—
    The design token to use for the component.
    stylesStylesOptions<ComponentInstance>—
    The styles to use for the component.
    render(instance: TreeRootInstance) => ReactNode—
    The render function to render the component with instance access.
    childrenany—
    The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
    valueTreeNodeData[]—
    An array of treenodes.
    expandedKeysTreeExpandedKeys—
    A record of keys to represent the state of the tree expansion state in controlled mode.
    defaultExpandedKeysTreeExpandedKeys—
    The default expanded keys when used in uncontrolled mode.
    selectionKeysTreeSelectionKeys | TreeCheckboxSelectionKeys—
    A record of keys to represent the selection state in controlled mode. For single/multiple mode: Record<string, boolean> For checkbox mode: Record<string, { checked: boolean, partialChecked: boolean }>
    defaultSelectionKeysTreeSelectionKeys | TreeCheckboxSelectionKeys—
    The default selected keys when used in uncontrolled mode.
    selectionMode"checkbox" | "multiple" | "single"—
    Defines the selection mode.
    metaKeySelectionbooleanfalse
    Defines how multiple items can be selected, when true metaKey needs to be pressed to select or unselect multiple items. When set to false selection of each item can be toggled individually.
    highlightOnSelectbooleanfalse
    Highlights automatically the first item.
    draggableboolean—
    Whether the tree nodes can be dragged.
    droppableboolean—
    Whether the tree can accept dropped nodes.
    draggableScopestring | string[]—
    Identifier(s) attached to nodes dragged out of this tree. Other trees use this value to decide whether they accept the drop (see `droppableScope` ). Accepts a string or an array of strings.
    droppableScopestring | string[]—
    Scope(s) this tree accepts drops from. A drop is allowed when the dragged node's `draggableScope` overlaps with this value. Accepts a string or an array of strings. When omitted, drops from any scope are accepted.
    onToggle(event: useTreeToggleEvent) => void—
    Callback fired when a node is toggled (expanded or collapsed).
    onExpand(event: useTreeExpandEvent) => void—
    Callback fired when a node is expanded.
    onCollapse(event: useTreeCollapseEvent) => void—
    Callback fired when a node is collapsed.
    onClick(event: useTreeClickEvent) => void—
    Callback fired when a node is clicked.
    onSelect(event: useTreeSelectEvent) => void—
    Callback fired when a node is selected.
    onUnselect(event: useTreeUnselectEvent) => void—
    Callback fired when a node is unselected.
    onMove(event: useTreeMoveEvent) => void—
    Callback fired when a drag-and-drop move completes. Receives the updated tree value plus move metadata.
    validateMove(event: useTreeMoveEvent) => boolean | Promise<boolean>—
    Optional validator invoked before a move is committed. Return `false` (sync or async) to cancel the move.
    onFocusedKeyChange(event: useTreeFocusedKeyChangeEvent) => void—
    Callback fired when the focused key changes (keyboard navigation).
    loadingboolean—
    Displays a loading overlay over the tree. Pair with `Tree.Loading` to render the spinner / message of your choice.
    onExpandedChange(event: TreeRootExpandedChangeEvent) => void—
    Callback fired when the tree's expanded keys state changes.
    onSelectionChange(event: TreeRootSelectionChangeEvent) => void—
    Callback fired when the tree's selection keys state changes.
    [key: string]any—
    pt-{optionName}-*-—
    Pass through attributes for customizing component. For more info, see Pass Through tab.
    AttributeValue
    data-scope"tree"
    data-part"root"
    data-dragoverPresent while a compatible drag is over the container

    Defines passthrough(pt) options of Tree component.

    labeltypedescription
    rootTreeRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.
    nodesTreeRootPassThroughType<HTMLAttributes<HTMLUListElement>>Used to pass attributes to the flat iterator's DOM element ( `<ul role="tree">` ).
    nodeTreeRootPassThroughType<HTMLAttributes<HTMLLIElement>>Used to pass attributes to the node's DOM element ( `<li>` ).
    contentTreeRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the content's DOM element (clickable row).
    labelTreeRootPassThroughType<HTMLAttributes<HTMLSpanElement>>Used to pass attributes to the label's DOM element.
    toggleTreeRootPassThroughType<ButtonHTMLAttributes<HTMLButtonElement>>Used to pass attributes to the toggle button's DOM element.
    toggleIndicatorTreeRootPassThroughType<HTMLAttributes<HTMLSpanElement>>Used to pass attributes to the toggle indicator's DOM element (state-matched icon slot).
    toggleSpacerTreeRootPassThroughType<HTMLAttributes<HTMLSpanElement>>Used to pass attributes to the toggle spacer rendered for leaf nodes.
    selectionTreeRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the selection slot (wraps user-provided checkbox/radio).
    pcFilterTreeRootPassThroughType<HTMLAttributes<HTMLElement>>Used to pass attributes to the filter's DOM element.
    headerTreeRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the header's DOM element.
    footerTreeRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the footer's DOM element.
    emptyTreeRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the empty message's DOM element.
    dropIndicatorTreeRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the drop indicator's DOM element.
    loadingTreeRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the loading overlay's DOM element.

    TreeNodes#

    NameTypeDefault
    refRef<unknown>—
    The reference to the component instance.
    pIfbooleantrue
    Whether the component should be rendered.
    styleCSSProperties | ((instance?: TreeNodesInstance) => CSSProperties)—
    The style to apply to the component.
    classNamestring | ((instance?: TreeNodesInstance) => string)—
    The class name to apply to the component.
    asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
    The component type to render.
    asChildbooleanfalse
    Whether the component should be rendered as a child component.
    instanceTreeNodesInstance—
    The instance to pass to the component.
    ptSafeRecord<TreeNodesPassThrough>—
    The pass-through props to pass to the component.
    ptOptionsPassThroughOptions—
    The pass-through options to pass to the component.
    unstyledboolean—
    Whether the component should be rendered without classes.
    dtunknown—
    The design token to use for the component.
    stylesStylesOptions<ComponentInstance>—
    The styles to use for the component.
    render(instance: TreeNodesInstance) => ReactNode—
    The render function to render the component with instance access.
    childrenReactNode | ((row: TreeNodeRow) => ReactNode)—
    Render-prop invoked once per visible node. Receives a `TreeNodeRow` payload carrying the node data plus its position and state in the tree.
    [key: string]any—
    pt-{optionName}-*-—
    Pass through attributes for customizing component. For more info, see Pass Through tab.
    AttributeValue
    data-scope"tree"
    data-part"nodes"
    role"tree"

    Defines passthrough(pt) options of TreeNodes component.

    labeltypedescription
    rootTreeNodesPassThroughType<HTMLAttributes<HTMLUListElement>>Used to pass attributes to the root's DOM element.

    TreeNode#

    NameTypeDefault
    refRef<unknown>—
    The reference to the component instance.
    pIfbooleantrue
    Whether the component should be rendered.
    styleCSSProperties | ((instance?: TreeNodeInstance) => CSSProperties)—
    The style to apply to the component.
    classNamestring | ((instance?: TreeNodeInstance) => string)—
    The class name to apply to the component.
    asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
    The component type to render.
    asChildbooleanfalse
    Whether the component should be rendered as a child component.
    instanceTreeNodeInstance—
    The instance to pass to the component.
    ptSafeRecord<TreeNodePassThrough>—
    The pass-through props to pass to the component.
    ptOptionsPassThroughOptions—
    The pass-through options to pass to the component.
    unstyledboolean—
    Whether the component should be rendered without classes.
    dtunknown—
    The design token to use for the component.
    stylesStylesOptions<ComponentInstance>—
    The styles to use for the component.
    render(instance: TreeNodeInstance) => ReactNode—
    The render function to render the component with instance access.
    childrenany—
    The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
    uKeystring—
    The key of the node to render. Looked up in the parent `Tree.Root` 's `nodeMap` . If the key is unknown (or omitted) a placeholder with `aria-busy` is rendered and a dev-mode warning is emitted.
    [key: string]any—
    pt-{optionName}-*-—
    Pass through attributes for customizing component. For more info, see Pass Through tab.
    AttributeValue
    data-scope"tree"
    data-part"node"
    data-node-keyNode key
    data-expandedPresent when expanded (non-leaf)
    data-collapsedPresent when collapsed (non-leaf)
    data-selectedPresent when selected
    data-leafPresent when leaf
    data-disabledPresent when disabled
    data-focusedPresent on the focused row

    Defines passthrough(pt) options of TreeNode component.

    labeltypedescription
    rootTreeNodePassThroughType<HTMLAttributes<HTMLLIElement>>Used to pass attributes to the root's DOM element.

    TreeContent#

    NameTypeDefault
    refRef<unknown>—
    The reference to the component instance.
    pIfbooleantrue
    Whether the component should be rendered.
    styleCSSProperties | ((instance?: TreeContentInstance) => CSSProperties)—
    The style to apply to the component.
    classNamestring | ((instance?: TreeContentInstance) => string)—
    The class name to apply to the component.
    asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
    The component type to render.
    asChildbooleanfalse
    Whether the component should be rendered as a child component.
    instanceTreeContentInstance—
    The instance to pass to the component.
    ptSafeRecord<TreeContentPassThrough>—
    The pass-through props to pass to the component.
    ptOptionsPassThroughOptions—
    The pass-through options to pass to the component.
    unstyledboolean—
    Whether the component should be rendered without classes.
    dtunknown—
    The design token to use for the component.
    stylesStylesOptions<ComponentInstance>—
    The styles to use for the component.
    render(instance: TreeContentInstance) => ReactNode—
    The render function to render the component with instance access.
    childrenany—
    The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
    [key: string]any—
    pt-{optionName}-*-—
    Pass through attributes for customizing component. For more info, see Pass Through tab.
    AttributeValue
    data-scope"tree"
    data-part"content"
    data-selectedPresent when selected or checked
    data-selectablePresent when selectable
    data-expandedPresent when expanded (non-leaf)
    data-collapsedPresent when collapsed (non-leaf)
    data-leafPresent when leaf
    data-checkedPresent when checked (checkbox mode)
    data-partial-checkedPresent when partially checked
    data-disabledPresent when disabled
    data-dragoverPresent while a compatible drag is over it

    Defines passthrough(pt) options of TreeContent component.

    labeltypedescription
    rootTreeContentPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

    TreeToggle#

    NameTypeDefault
    refRef<unknown>—
    The reference to the component instance.
    pIfbooleantrue
    Whether the component should be rendered.
    styleCSSProperties | ((instance?: TreeToggleInstance) => CSSProperties)—
    The style to apply to the component.
    classNamestring | ((instance?: TreeToggleInstance) => string)—
    The class name to apply to the component.
    asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
    The component type to render.
    asChildbooleanfalse
    Whether the component should be rendered as a child component.
    instanceTreeToggleInstance—
    The instance to pass to the component.
    ptSafeRecord<TreeTogglePassThrough>—
    The pass-through props to pass to the component.
    ptOptionsPassThroughOptions—
    The pass-through options to pass to the component.
    unstyledboolean—
    Whether the component should be rendered without classes.
    dtunknown—
    The design token to use for the component.
    stylesStylesOptions<ComponentInstance>—
    The styles to use for the component.
    render(instance: TreeToggleInstance) => ReactNode—
    The render function to render the component with instance access.
    childrenany—
    The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
    [key: string]any—
    pt-{optionName}-*-—
    Pass through attributes for customizing component. For more info, see Pass Through tab.
    AttributeValue
    data-scope"tree"
    data-part"toggle"
    data-expandedPresent when expanded
    data-collapsedPresent when collapsed

    For leaf nodes the toggle is replaced by <span data-part="toggle-spacer" aria-hidden>.

    Defines passthrough(pt) options of TreeToggle component.

    labeltypedescription
    rootTreeTogglePassThroughType<ButtonHTMLAttributes<HTMLButtonElement>>Used to pass attributes to the root's DOM element.

    TreeToggleIndicator#

    NameTypeDefault
    refRef<unknown>—
    The reference to the component instance.
    pIfbooleantrue
    Whether the component should be rendered.
    styleCSSProperties | ((instance?: TreeToggleIndicatorInstance) => CSSProperties)—
    The style to apply to the component.
    classNamestring | ((instance?: TreeToggleIndicatorInstance) => string)—
    The class name to apply to the component.
    asReactNode—
    The component type to render.
    asChildbooleanfalse
    Whether the component should be rendered as a child component.
    instanceTreeToggleIndicatorInstance—
    The instance to pass to the component.
    ptSafeRecord<TreeToggleIndicatorPassThrough>—
    The pass-through props to pass to the component.
    ptOptionsPassThroughOptions—
    The pass-through options to pass to the component.
    unstyledboolean—
    Whether the component should be rendered without classes.
    dtunknown—
    The design token to use for the component.
    stylesStylesOptions<ComponentInstance>—
    The styles to use for the component.
    render(instance: TreeToggleIndicatorInstance) => ReactNode—
    The render function to render the component with instance access.
    childrenany—
    The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
    match"always" | "expanded" | "collapsed"—
    Determines the visibility of the indicator based on the toggle state. - "expanded": Visible when the node is expanded. - "collapsed": Visible when the node is collapsed. - "always": Indicator is always visible (useful for loading spinners).
    pt-{optionName}-*-—
    Pass through attributes for customizing component. For more info, see Pass Through tab.
    AttributeValue
    data-scope"tree"
    data-part"toggle-indicator"

    Defines passthrough(pt) options of TreeToggleIndicator component.

    labeltypedescription
    rootTreeToggleIndicatorPassThroughType<HTMLAttributes<HTMLSpanElement>>Used to pass attributes to the root's DOM element.

    TreeSelection#

    NameTypeDefault
    refRef<unknown>—
    The reference to the component instance.
    pIfbooleantrue
    Whether the component should be rendered.
    styleCSSProperties | ((instance?: TreeSelectionInstance) => CSSProperties)—
    The style to apply to the component.
    classNamestring | ((instance?: TreeSelectionInstance) => string)—
    The class name to apply to the component.
    asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
    The component type to render.
    asChildbooleanfalse
    Whether the component should be rendered as a child component.
    instanceTreeSelectionInstance—
    The instance to pass to the component.
    ptSafeRecord<TreeSelectionPassThrough>—
    The pass-through props to pass to the component.
    ptOptionsPassThroughOptions—
    The pass-through options to pass to the component.
    unstyledboolean—
    Whether the component should be rendered without classes.
    dtunknown—
    The design token to use for the component.
    stylesStylesOptions<ComponentInstance>—
    The styles to use for the component.
    render(instance: TreeSelectionInstance) => ReactNode—
    The render function to render the component with instance access.
    childrenany—
    The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
    mode"checkbox" | "radio" | "single"—
    Override the toggle mode used inside the render-prop. - 'radio': select only one node, no deselect on re-click. - 'checkbox': tri-state with cascade propagation. - 'single': select one node, deselect on re-click. When omitted, defaults to `'single'` for `selectionMode="single"` , `'checkbox'` for `selectionMode="checkbox"` , otherwise `'checkbox'` .
    [key: string]any—
    pt-{optionName}-*-—
    Pass through attributes for customizing component. For more info, see Pass Through tab.

    Render-prop only; no DOM attributes of its own.

    Defines passthrough(pt) options of TreeSelection component.

    labeltypedescription
    rootTreeSelectionPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

    TreeDropIndicator#

    NameTypeDefault
    refRef<unknown>—
    The reference to the component instance.
    pIfbooleantrue
    Whether the component should be rendered.
    styleCSSProperties | ((instance?: TreeDropIndicatorInstance) => CSSProperties)—
    The style to apply to the component.
    classNamestring | ((instance?: TreeDropIndicatorInstance) => string)—
    The class name to apply to the component.
    asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
    The component type to render.
    asChildbooleanfalse
    Whether the component should be rendered as a child component.
    instanceTreeDropIndicatorInstance—
    The instance to pass to the component.
    ptSafeRecord<TreeDropIndicatorPassThrough>—
    The pass-through props to pass to the component.
    ptOptionsPassThroughOptions—
    The pass-through options to pass to the component.
    unstyledboolean—
    Whether the component should be rendered without classes.
    dtunknown—
    The design token to use for the component.
    stylesStylesOptions<ComponentInstance>—
    The styles to use for the component.
    render(instance: TreeDropIndicatorInstance) => ReactNode—
    The render function to render the component with instance access.
    childrenany—
    The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
    position"after" | "before"—
    Which drop point this indicator represents. Render two siblings of `Tree.Content` — one with `position="before"` and one with `position="after"` . Each renders only while its respective drop point is active.
    [key: string]any—
    pt-{optionName}-*-—
    Pass through attributes for customizing component. For more info, see Pass Through tab.

    Renders only while the matching drop point is hovered. Use one with position="before" and one with position="after" per Tree.Node.

    AttributeValue
    data-scope"tree"
    data-part"drop-point"

    Defines passthrough(pt) options of TreeDropIndicator component.

    labeltypedescription
    rootTreeDropIndicatorPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

    TreeLabel#

    NameTypeDefault
    refRef<unknown>—
    The reference to the component instance.
    pIfbooleantrue
    Whether the component should be rendered.
    styleCSSProperties | ((instance?: TreeLabelInstance) => CSSProperties)—
    The style to apply to the component.
    classNamestring | ((instance?: TreeLabelInstance) => string)—
    The class name to apply to the component.
    asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
    The component type to render.
    asChildbooleanfalse
    Whether the component should be rendered as a child component.
    instanceTreeLabelInstance—
    The instance to pass to the component.
    ptSafeRecord<TreeLabelPassThrough>—
    The pass-through props to pass to the component.
    ptOptionsPassThroughOptions—
    The pass-through options to pass to the component.
    unstyledboolean—
    Whether the component should be rendered without classes.
    dtunknown—
    The design token to use for the component.
    stylesStylesOptions<ComponentInstance>—
    The styles to use for the component.
    render(instance: TreeLabelInstance) => ReactNode—
    The render function to render the component with instance access.
    childrenany—
    The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
    [key: string]any—
    pt-{optionName}-*-—
    Pass through attributes for customizing component. For more info, see Pass Through tab.

    Defines passthrough(pt) options of TreeLabel component.

    labeltypedescription
    rootTreeLabelPassThroughType<HTMLAttributes<HTMLSpanElement>>Used to pass attributes to the root's DOM element.

    TreeFilter#

    NameTypeDefault
    refRef<unknown>—
    The reference to the component instance.
    pIfbooleantrue
    Whether the component should be rendered.
    styleCSSProperties | ((instance?: TreeFilterInstance) => CSSProperties)—
    The style to apply to the component.
    classNamestring | ((instance?: TreeFilterInstance) => string)—
    The class name to apply to the component.
    asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
    The component type to render.
    asChildbooleanfalse
    Whether the component should be rendered as a child component.
    instanceTreeFilterInstance—
    The instance to pass to the component.
    ptSafeRecord<TreeFilterPassThrough>—
    The pass-through props to pass to the component.
    ptOptionsPassThroughOptions—
    The pass-through options to pass to the component.
    unstyledboolean—
    Whether the component should be rendered without classes.
    dtunknown—
    The design token to use for the component.
    stylesStylesOptions<ComponentInstance>—
    The styles to use for the component.
    render(instance: TreeFilterInstance) => ReactNode—
    The render function to render the component with instance access.
    childrenany—
    The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
    [key: string]any—
    pt-{optionName}-*-—
    Pass through attributes for customizing component. For more info, see Pass Through tab.
    AttributeValue
    data-scope"tree"
    data-part"filter"

    Defines passthrough(pt) options of TreeFilter component.

    labeltypedescription
    rootTreeFilterPassThroughType<HTMLAttributes<HTMLElement>>Used to pass attributes to the root's DOM element.

    TreeHeader#

    NameTypeDefault
    refRef<unknown>—
    The reference to the component instance.
    pIfbooleantrue
    Whether the component should be rendered.
    styleCSSProperties | ((instance?: TreeHeaderInstance) => CSSProperties)—
    The style to apply to the component.
    classNamestring | ((instance?: TreeHeaderInstance) => string)—
    The class name to apply to the component.
    asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
    The component type to render.
    asChildbooleanfalse
    Whether the component should be rendered as a child component.
    instanceTreeHeaderInstance—
    The instance to pass to the component.
    ptSafeRecord<TreeHeaderPassThrough>—
    The pass-through props to pass to the component.
    ptOptionsPassThroughOptions—
    The pass-through options to pass to the component.
    unstyledboolean—
    Whether the component should be rendered without classes.
    dtunknown—
    The design token to use for the component.
    stylesStylesOptions<ComponentInstance>—
    The styles to use for the component.
    render(instance: TreeHeaderInstance) => ReactNode—
    The render function to render the component with instance access.
    childrenany—
    The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
    [key: string]any—
    pt-{optionName}-*-—
    Pass through attributes for customizing component. For more info, see Pass Through tab.

    Defines passthrough(pt) options of TreeHeader component.

    labeltypedescription
    rootTreeHeaderPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

    TreeFooter#

    NameTypeDefault
    refRef<unknown>—
    The reference to the component instance.
    pIfbooleantrue
    Whether the component should be rendered.
    styleCSSProperties | ((instance?: TreeFooterInstance) => CSSProperties)—
    The style to apply to the component.
    classNamestring | ((instance?: TreeFooterInstance) => string)—
    The class name to apply to the component.
    asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
    The component type to render.
    asChildbooleanfalse
    Whether the component should be rendered as a child component.
    instanceTreeFooterInstance—
    The instance to pass to the component.
    ptSafeRecord<TreeFooterPassThrough>—
    The pass-through props to pass to the component.
    ptOptionsPassThroughOptions—
    The pass-through options to pass to the component.
    unstyledboolean—
    Whether the component should be rendered without classes.
    dtunknown—
    The design token to use for the component.
    stylesStylesOptions<ComponentInstance>—
    The styles to use for the component.
    render(instance: TreeFooterInstance) => ReactNode—
    The render function to render the component with instance access.
    childrenany—
    The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
    [key: string]any—
    pt-{optionName}-*-—
    Pass through attributes for customizing component. For more info, see Pass Through tab.

    Defines passthrough(pt) options of TreeFooter component.

    labeltypedescription
    rootTreeFooterPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

    TreeEmpty#

    NameTypeDefault
    refRef<unknown>—
    The reference to the component instance.
    pIfbooleantrue
    Whether the component should be rendered.
    styleCSSProperties | ((instance?: TreeEmptyInstance) => CSSProperties)—
    The style to apply to the component.
    classNamestring | ((instance?: TreeEmptyInstance) => string)—
    The class name to apply to the component.
    asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
    The component type to render.
    asChildbooleanfalse
    Whether the component should be rendered as a child component.
    instanceTreeEmptyInstance—
    The instance to pass to the component.
    ptSafeRecord<TreeEmptyPassThrough>—
    The pass-through props to pass to the component.
    ptOptionsPassThroughOptions—
    The pass-through options to pass to the component.
    unstyledboolean—
    Whether the component should be rendered without classes.
    dtunknown—
    The design token to use for the component.
    stylesStylesOptions<ComponentInstance>—
    The styles to use for the component.
    render(instance: TreeEmptyInstance) => ReactNode—
    The render function to render the component with instance access.
    childrenany—
    The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
    [key: string]any—
    pt-{optionName}-*-—
    Pass through attributes for customizing component. For more info, see Pass Through tab.

    Defines passthrough(pt) options of TreeEmpty component.

    labeltypedescription
    rootTreeEmptyPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

    TreeLoading#

    NameTypeDefault
    refRef<unknown>—
    The reference to the component instance.
    pIfbooleantrue
    Whether the component should be rendered.
    styleCSSProperties | ((instance?: TreeLoadingInstance) => CSSProperties)—
    The style to apply to the component.
    classNamestring | ((instance?: TreeLoadingInstance) => string)—
    The class name to apply to the component.
    asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
    The component type to render.
    asChildbooleanfalse
    Whether the component should be rendered as a child component.
    instanceTreeLoadingInstance—
    The instance to pass to the component.
    ptSafeRecord<TreeLoadingPassThrough>—
    The pass-through props to pass to the component.
    ptOptionsPassThroughOptions—
    The pass-through options to pass to the component.
    unstyledboolean—
    Whether the component should be rendered without classes.
    dtunknown—
    The design token to use for the component.
    stylesStylesOptions<ComponentInstance>—
    The styles to use for the component.
    render(instance: TreeLoadingInstance) => ReactNode—
    The render function to render the component with instance access.
    childrenany—
    The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
    [key: string]any—
    pt-{optionName}-*-—
    Pass through attributes for customizing component. For more info, see Pass Through tab.

    Renders only while Tree.Root.loading is true. Use it as a sibling of Tree.Nodes.

    AttributeValue
    data-scope"tree"
    data-part"loading"
    role"status"

    Defines passthrough(pt) options of TreeLoading component.

    labeltypedescription
    rootTreeLoadingPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

    Accessibility#

    Screen Reader#

    The flat <ul role="tree"> contains one <li role="treeitem"> per visible row. Each row carries aria-level, aria-posinset and aria-setsize. Non-leaf rows set aria-expanded. In selectionMode="checkbox", aria-checked is true, false or "mixed".

    Keyboard Support#

    KeyFunction
    tab / shift + tabEnter / leave the tree.
    enter / spaceToggle selection on the focused node.
    down arrowMove focus to the next visible row.
    up arrowMove focus to the previous visible row.
    right arrowExpand the focused node, or step into its first child.
    left arrowCollapse the focused node, or step out to its parent.
    home / endJump to the first / last visible row.
    Printable charactersType-ahead by label (500 ms reset).