Selected: src/components/ui/button.jsx
Installation
$ pnpm dlx shadcn@latest add @synccn/file-treeFirst time in this project? Connect synccn with one command.
Usage
import { FileTree } from "@/components/ui/file-tree";<FileTree data={tree} defaultExpanded={["src"]} />API reference
Generated from the component's TypeScript types, so it always matches the code.
FileTree
Expandable tree for files and folders, with keyboard support (Up/Down to move, Right to open, Left to close, Enter to select). data: [{ name, children?: [...] }]
PropTypeDescription
- datarequired
FileNode[]Top-level files and folders.
- defaultExpanded
string[]Default
[]Folder paths open at first, e.g. "src/components".
- onSelect
(path: string) => voidCalled with a file's path when it's chosen.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Helpers
- lib/utilscn (merges class names)
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for ChevronRight, File, FileCode2, FileJson, FileText, Folder, FolderOpen, Image
Keyboard
- ↓or↑Move between rows
- →Open a folder
- ←Close a folder
- EnterOpen a folder or choose a file
Accessibility
- Uses tree and treeitem roles with aria-expanded on folders and aria-selected on the chosen file.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: tree, treeitem
- ARIA attributes: aria-expanded, aria-selected
- Keys handled: ArrowUp, ArrowDown, ArrowLeft, ArrowRight
- Shows a visible focus ring for keyboard users
More display
CardSurface with header, content and footer slots.BadgeSmall status label with an optional dot.AvatarImage with initials fallback, presence dot and stacked groups.KbdKeyboard key for shortcuts and hints.SeparatorHorizontal, vertical or labelled divider.AccordionExpanding sections with smooth height animation.