Tree Checkbox
Nested checkboxes with cascade select. Checking a parent selects every descendant; partial children show the parent as indeterminate. Branches collapse with logical indent for LTR and RTL.
Gallery
Permissions tree with cascade select. Toggle Documents — parents show indeterminate when partial.
Loading…
Installation
CLI
Also needs
npx @sonojs/ui@latest add checkbox collapsiblenpm i lucide-reactUsage
tree-checkbox.tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| data | TreeCheckboxNode[] | - | Forest of nodes (`id`, `label`, optional `children` / `disabled`). |
| value | string[] | - | Controlled checked node ids (includes fully selected parents). |
| defaultValue | string[] | [] | Initial checked ids when uncontrolled. |
| onValueChange | (value: string[]) => void | - | Fires after cascade toggle. |
| expanded | string[] | - | Controlled open branch ids. |
| defaultExpanded | string[] | [] | Initial open branches when uncontrolled. |
| onExpandedChange | (expanded: string[]) => void | - | Fires when a branch opens or closes. |
| disabled | boolean | false | Disables the entire tree. |
| className | string | - | Merged onto the tree root. |
Related
- Checkbox, leaf control + indeterminate dash
- Collapsible, expand and collapse branches
- Field, label and describe the tree