Installation
npx shadcn@latest add @iconiq/file-treeProps
FileTree
8 props
Root provider for the compound file tree. Tracks expanded folders, hover highlight bounds, and shared visual settings.
defaultExpandedIds
string[]Default
[]Folder node ids that should start expanded on first render.
highlightColor
stringDefault
#3b82f6Text color applied to items with `highlight` on `FileTreeItem`.
indentSize
numberDefault
24Horizontal indent in pixels for each nested folder level.
showIcons
booleanDefault
trueWhether to render icons. File icons are inferred from the label extension when no custom icon is provided.
onNodeClick
(nodeId: string) => voidCalled when a file or folder row is activated.
onNodeExpand
(nodeId: string, expanded: boolean) => voidCalled when a folder branch opens or closes.
className
stringOptional class names applied to the bordered root container.
children
React.ReactNodeUsually a single `FileTreeList` with nested `FileTreeItem` rows.
Notes
Wrap `FileTreeList` and nested `FileTreeItem` components inside the root provider.
Hovering any row updates a single animated highlight that follows the active item inside the tree container.
FileTreeList
2 props
Semantic tree container for top-level and nested file rows. Supports Base UI `render` composition instead of Radix Slot.
className
stringMerged with the default vertical stack layout.
render
ReactElement | ((props) => ReactElement)Optional Base UI render override for the list container element.
FileTreeItem
6 props
Single file or folder row. Nested children render as an animated branch when the row is expandable.
nodeId
stringRequired
Stable unique id used for expand state, callbacks, and tree semantics.
label
stringRequired
Display label for the row. File extension is used to pick a default icon.
icon
React.ReactNodeOptional custom icon node rendered before the label.
hasChildren
booleanMarks the row as a branch even when it has no nested children yet. Otherwise inferred from child items.
highlight
booleanWhen true, tints the row with `highlightColor` to mark it as new or relevant.
children
React.ReactNodeNested `FileTreeItem` rows rendered when the branch is expanded.
Notes
Folder rows use Base UI Button for the toggle control while file rows remain static display rows.
Folder icons swap with a spring transition, and child lists animate open and closed with height and opacity motion.