Skip to content

UITreeView

File tree
format.tsadded
helpers.tsmodified
index.tsmodified
server.tsadded
index.test.tsmodified
package.jsonmodified

UITreeView renders a tree built from flat data using buildTree():

import { buildTree, UITreeView } from "tango-api";
const files = [
{ path: "src/index.ts" },
{ path: "src/utils/helpers.ts" },
];
const tree = buildTree(files, (f) => f.path);
// Creates: root → src/ → [index.ts, utils/ → helpers.ts]
PropTypeDefaultDescription
nodeTreeNode<T>requiredRoot tree node from buildTree()
activeItemstring | nullPath of the currently active item
itemPath(item: T) => stringrequiredExtracts the path from an item
onItemClick(path: string) => voidCalled when an item is clicked
renderItemMeta(item: T) => ReactNodeCustom metadata for each item
renderItemIcon(item: T) => ReactNodeCustom icon for each item
renderDirMeta(dir: TreeNode<T>) => ReactNodeCustom metadata for directories
import { UITreeView, buildTree, UIBadge } from "tango-api";
const tree = buildTree(changedFiles, (f) => f.path);
<UITreeView
node={tree}
itemPath={(f) => f.path}
activeItem={selectedFile}
onItemClick={setSelectedFile}
renderItemMeta={(f) => <UIBadge label={f.status} tone="info" />}
/>