Skip to content
TrademarkTrademark
Docs
Components

FileTree

Updated: October 19, 2026
View on GitHub

FileTree displays nested files and folders. Use the arrow keys to move through visible rows, expand or collapse folders, and select an item.

Data model

Each item has a unique id, a display name, and a discriminating type. Files may provide an optional icon; folders contain a recursive children array.

Controlled selection and expansion

Use selectedId with onSelect to control selection, and expandedIds with onExpandChange to control open folders. Omit those state props to let the component manage the state internally; use defaultSelectedId and defaultExpandedIds for initial state.

onItemClick reports pointer clicks. renderItem replaces the row label and receives the item plus its selected, expanded, and depth state. emptyState and loadingState customize the corresponding placeholders; set loading to show the loading state.

API reference

Type
Default
itemsrequired
FileTreeItem[]—
selectedId
stringnull
—
defaultSelectedId
string—
expandedIds
string[]—
defaultExpandedIds
string[][]
onSelect
(item: FileTreeItem) => void—
onExpandChange
(expandedIds: string[], item: FileTreeFolder) => void—
onItemClick
(item: FileTreeItem) => void—
renderItem
( item: FileTreeItem, state: { selected: boolean; expanded: boolean; depth: number }, ) => React.ReactNode—
emptyState
React.ReactNode—
loading
booleanfalse
loadingState
React.ReactNode—
aria-label
string—
…and every FlexProps propinherited—

Keyboard interaction

  • Up and Down move between visible rows; Home and End move to the first and last row.
  • Right opens a closed folder or focuses its first child.
  • Left closes an open folder or focuses its parent.
  • Enter and Space select the focused item.

The component uses the ARIA tree pattern and exposes selection and expansion state to assistive technology.

Edit this page on GitHub