Hierarchical tree view component with ASCII styling and expandable nodes.
npm install react-ascii-ui
import { AsciiTree } from 'react-ascii-ui';
const treeData = [
{
id: 'root',
label: 'Project Root',
children: [
{ id: 'src', label: 'src/', children: [...] },
{ id: 'docs', label: 'docs/', children: [...] }
]
}
];
export default function App() {
const [selectedNode, setSelectedNode] = useState(null);
return (
<AsciiTree
data={treeData}
onNodeSelect={setSelectedNode}
expandable={true}
showIcons={true}
/>
);
}| Prop | Type | Default | Description |
|---|---|---|---|
| data | TreeNode[] | - | Tree data structure |
| expandable | boolean | true | Enable node expansion/collapse |
| showIcons | boolean | true | Show node icons |
| selectable | boolean | false | Enable node selection |
| onNodeSelect | (node: TreeNode) => void | undefined | Node selection callback |
| onNodeExpand | (node: TreeNode) => void | undefined | Node expansion callback |
| defaultExpanded | string[] | [] | Default expanded node IDs |