Add icons and checkboxes to Tree nodes
masterThe Tree component supports visual enhancements through the icon and isChecked properties in the data objects.
- Icons: Pass any React element (e.g.,
<FileIcon />) to theiconproperty of a node. - Checkboxes: Use the
isCheckedproperty. It supportstrue,false, and'indeterminate'states. Use theonNodeCheckprop to handle user interactions and implement logic for parent/child selection synchronization.
const data = [
{
label: 'Tree Item',
icon: <FileIcon />,
isChecked: false
},
{
label: 'Tree Branch',
icon: <FolderCloseIcon />,
children: [
{ label: 'Child Item', isChecked: true }
]
}
];