TreeView
@spartanfx/react / TreeView
Function: TreeView()
TreeView<
TItem>(props):Element
A production-ready, enterprise-grade hierarchical tree view component.
Features:
- Supports both flat (id/parentId) and nested (children) data structures
- Custom icons per level or per node
- Optional custom item rendering
- Native HTML5 drag & drop reordering
- Responsive burger menu on small screens
- Context API for external control
- Themeable via CSS custom properties
Type Parameters
TItem
TItem = any
Parameters
props
ITreeViewProps<TItem>
Returns
Element
Example
<TreeView
items={[
{ id: '1', parentId: null, name: 'Root' },
{ id: '2', parentId: '1', name: 'Child' },
]}
schema={{
idField: 'id',
parentIdField: 'parentId',
labelField: 'name',
}}
enableDragDrop
onReOrder={(event) => setItems(event.items)}
/>