Özer

Tree View

Navigation 79

About

An accessible file-explorer tree view with full keyboard navigation, animated expand/collapse disclosure, and single selection.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Tree View to your project and fits it to your theme.

Code

How Tree View is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { TreeView, type TreeNode } from "@/components/ui/tree-view";

const NODES: TreeNode[] = [
  {
    id: "components",
    label: "components",
    children: [
      {
        id: "interior",
        label: "interior",
        children: [
          { id: "tabs", label: "tabs.tsx", meta: "9 kB" },
          { id: "dropdown", label: "dropdown.tsx", meta: "7 kB" },
          { id: "tree-view", label: "tree-view.tsx", meta: "8 kB" },
        ],
      },
      {
        id: "site",
        label: "site",
        children: [
          { id: "sidebar", label: "sidebar.tsx", meta: "5 kB" },
          { id: "wordmark", label: "wordmark.tsx", meta: "1 kB" },
        ],
      },
    ],
  },
  {
    id: "lib",
    label: "lib",
    children: [
      { id: "registry", label: "registry.ts", meta: "4 kB" },
      { id: "demos-index", label: "demos/index.tsx", meta: "3 kB" },
    ],
  },
  { id: "design", label: "DESIGN.md", meta: "38 kB" },
];

export default function TreeViewDemo() {
  return (
    <div className="mx-auto w-full max-w-[300px]">
      <TreeView
        nodes={NODES}
        label="Project files"
        defaultExpanded={["components", "interior"]}
        defaultSelected="tabs"
      />
    </div>
  );
}

Dependencies

More by Özer

View all
  • Password Strength

    Password Strength

    1.3K
  • OTP Input

    OTP Input

    799
  • Loading Button

    Loading Button

    599
  • Progress Bar

    Progress Bar

    586
  • Reorder List

    Reorder List

    308
  • Task Steps

    Task Steps

    275
  • Hold to Confirm

    Hold to Confirm

    249
  • Reading Progress

    Reading Progress

    168

More in Navigation

View all
  • Sidebar

    Sidebar

    231
  • Tabs

    Tabs

    60
  • Progress Bar Stepper

    Progress Bar Stepper

    36
  • Newsletter Signup Footer

    Newsletter Signup Footer

    15
  • Footer 2

    Footer 2

    200
  • Navbar with Theme Toggle

    Navbar with Theme Toggle

    43
  • Numberless Pagination with Text

    Numberless Pagination with Text

    11
  • Navbar

    Navbar

    71

Explore more

Part of interior.dev — browse the full library on 21st.dev.