HomeDocsComponentsBlocksChartsThemes
Introduction
  • Introduction
  • Installation
  • Themes
  • llms.txt
Components
  • Accordion
  • Alert
  • Alert Dialog
  • Amount
  • Aspect Ratio
  • Audio Player
  • Avatar
  • Avatar Upload
  • Badge
  • Banner
  • Breadcrumb
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Code Block
  • Collapsible
  • Color Picker
  • Combobox
  • Command
  • Context Menu
  • Copy Button
  • Countdown
  • Data Grid
  • Data Table
  • Date Picker
  • Date Range Picker
  • Description List
  • Device Mockup
  • Dialog
  • Direction
  • Dot Loader
  • Drawer
  • Dropdown Menu
  • Empty
  • Field
  • File Upload
  • Hover Card
  • Input
  • Input Group
  • Input OTP
  • Item
  • Kanban
  • Kbd
  • Label
  • Menubar
  • Meter
  • Multi Select
  • Native Select
  • Navigation Menu
  • Number Field
  • Pagination
  • Password Strength
  • Phone Input
  • Popover
  • Progress
  • Progress Circle
  • Radio Group
  • Rating
  • Resizable
  • Responsive Dialog
  • Rich Text Editor
  • Scroll Area
  • Segmented Control
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature
  • Skeleton
  • Slider
  • Sortable
  • Spinner
  • Stat
  • Stepper
  • Switch
  • Table
  • Tabs
  • Tag Input
  • Terminal
  • Textarea
  • Time Field
  • Timeline
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Tree
  • Typography
  • Video Player
  • Window Mockup
AI
  • Message Scroller
  • Message
  • Bubble
  • Marker
  • Attachment
  • Questionnaire
  • Composer
  • Reasoning
  • Tool Call
  • Approval Card
  • Citations
Blocks
  • Airtable
  • Airtable Kanban
  • ClickUp List
  • ClickUp Kanban
  • Repeatable Group
  • Command Palette
  • Sign In and Sign Up
  • Availability Scheduler
  • AI Chat
  • Action Bar
  • Notion
  • Banking
  • Lineup Builder
  • Sports Score
  • Strava
  • Sheets
  • Notices
  • Settings
  • Billing
Utilities
  • motion
  • sounds
  • scroll-fade
  • shimmer
Another UI. Built on shadcn/ui with Phosphor icons.

Tree

PreviousNext

A file tree or nested list that opens branch by branch, with search, keyboard navigation, and single, multiple or checkbox selection.

Base UIReact AriaRadix UI

vwork-app

  • app
    • invoices
      • page.tsx
      • [id]
      • actions.tsM
    • clients
    • layout.tsx
    • globals.css
  • lib
  • db
  • public
  • README.md
  • package.json

Open: app/invoices/actions.ts

Bookkeeper access

  • Clients
    • Acme Supply
      • View invoices
      • Edit invoices
      • Contacts
    • Northwind Dental
      • View invoices
      • Edit invoices
      • Contacts
  • Settings

4 permissions granted

Installation#

pnpm dlx shadcn@latest add https://anotherui.dev/r/tree.json

Usage#

import { Tree, type TreeItem } from "@/components/ui/tree"
const items: TreeItem[] = [
  {
    id: "app",
    label: "app",
    children: [
      { id: "app/page.tsx", label: "page.tsx" },
      { id: "app/layout.tsx", label: "layout.tsx" },
    ],
  },
  { id: "README.md", label: "README.md" },
]
 
<Tree
  aria-label="Project files"
  items={items}
  defaultExpanded={["app"]}
  onSelectedChange={(ids) => open(ids[0])}
  searchable
/>

Selection#

  • single. The default. Clicking an item selects it. Cmd or Ctrl click adds to the selection.
  • multiple. Each click toggles an item.
  • checkbox. Each item gets a checkbox. Checking a branch checks every enabled leaf below it, and a branch with some leaves checked shows a dash. selected holds the checked leaves.
  • none. Items open and close but are never selected.

Keyboard#

  • Up and Down move between visible items. Home and End jump to the first and last.
  • Right opens a branch, or moves to its first child when it is already open.
  • Left closes a branch, or moves to its parent.
  • Enter selects and calls onAction. Space selects.
  • * opens every branch at the same level.
  • Typing a letter moves to the next item that starts with it.

Props#

  • items. { id, label, icon?, children?, badge?, disabled? }. Items with children are branches.
  • expanded, defaultExpanded, onExpandedChange. The open branches, by id.
  • selected, defaultSelected, onSelectedChange. The selected ids.
  • selectionMode. single, multiple, checkbox or none.
  • onAction. Called with the item on Enter or click.
  • searchable. Adds a search field. Matches are highlighted and every branch that holds one opens.
  • folderIcons. Folder and file icons for items without their own icon. On by default. Files get an icon from their extension.
TooltipTypography

On This Page

InstallationUsageSelectionKeyboardProps