Tree list

Hierarchical list with expand/collapse, selection, and depth indentation. Ideal for layer panels with nested frames.

Install

npx shadcn@latest add https://substrate.georgedrury.co.uk/r/tree-list

Examples

Default

Page
Header
Logo
Navigation
Footer
"use client"

import { useState } from "react"

Components

ComponentDescription
TreeListRoot container with role="tree"
TreeItemRow with depth, selection, expand/collapse
TreeExpandButtonChevron toggle that rotates when expanded
TreeItemContentTruncated text label
TreeItemIconColour dot or icon
TreeItemActionsRight-aligned actions, visible on hover

Hooks

useTreeExpansion

Manages expand/collapse state for a set of node IDs.

const { isExpanded, toggle, expandAll, collapseAll } = useTreeExpansion([
	"root",
])
MethodDescription
isExpandedCheck if a node is expanded
toggleToggle a node's expanded state
expandAllExpand a list of node IDs
collapseAllCollapse all nodes