Skip to content
프로젝트

소개

중첩된 계층을 펼치거나 접을 수 있는 계층형 데이터 목록용 Shadcn UI 컴포넌트입니다.

웹 및 앱 개발

이 수치를 측정하는 방법

What you can do

  • 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).

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

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 gif

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

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

Usage

Props

Tree View

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

Tree Item

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

Basic

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,
  },
];

<TreeView data={data} />;

Roadmap

Alternatives

License

Licensed under the MIT license, see LICENSE.

관련 프로젝트 살펴보기

불러오는 중…