百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

shadcn-tree-view

> 前端框架
开源

一个 Shadcn UI 组件,用于具有可展开和收缩的嵌套级别的数据层次化列表。

394 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

一个 Shadcn UI 组件,用于具有可展开和收缩的嵌套级别的数据层次化列表。

Tree View - Shadcn UI

The Tree View component allows you to navigate hierarchical lists of data with nested levels that can be expanded and collapsed.

Based on implementation by WangLarry and bytechase.

DEMO

Tree View Table (advanced)

Features

  • Expand, collapse, and select items.
  • Custom icons per item (default, open, selected).
  • Default node & leaf icons per tree view.
  • Action buttons (e.g. a button to add a new item).
  • Click handlers per tree item and per the entire tree view.
  • Drag & drop support.
  • Disabled state.
  • Custom item renderers.

Installation

bash
npx shadcn add "https://mrlightful.com/registry/tree-view"

Usage

Props

Tree View

typescript
type TreeProps = React.HTMLAttributes & {
  data: TreeDataItem[] | TreeDataItem;
  initialSelectedItemId?: string;
  onSelectChange?: (item: TreeDataItem | undefined) => void;
  renderItem?: (params: TreeRenderItemParams) => React.ReactNode;
  expandAll?: boolean;
  defaultNodeIcon?: React.ComponentType;
  defaultLeafIcon?: React.ComponentType;
};

Tree Item

typescript
interface TreeDataItem {
  id: string;
  name: string;
  icon?: React.ComponentType;
  selectedIcon?: React.ComponentType;
  openIcon?: React.ComponentType;
  children?: TreeDataItem[];
  actions?: React.ReactNode;
  onClick?: () => void;
  draggable?: boolean;
  droppable?: boolean;
  disabled?: boolean;
  className?: string;
}

Basic

typescript
import { TreeView, TreeDataItem } from "@/components/ui/tree-view";

const data: TreeDataItem[] = [
  {
    id: "1",
    name: "Item 1",
    children: [
      {
        id: "2",
        name: "Item 1.1",
        children: [
          {
            id: "3",
            name: "Item 1.1.1",
          },
          {
            id: "4",
            name: "Item 1.1.2",
          },
        ],
      },
      {
        id: "5",
        name: "Item 1.2 (disabled)",
        disabled: true,
      },
    ],
  },
  {
    id: "6",
    name: "Item 2 (draggable)",
    draggable: true,
  },
];

;

Roadmap

  • Add support for programmatically controlling items (https://github.com/romatallinn/shadcn-tree-view/issues/2).

Alternatives

  • Kibo UI / Tree
  • ReUI / Tree
  • Coss / Tree

License

Licensed under the MIT license, see LICENSE.

Issues· 10 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptcollapsecollapsiblecomponentnested

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架