Overview
Use Checkbox Tree to select items from a hierarchy whose levels open and close, such as subjects and their assessments when setting an assessment, or year groups, classes and pupils.
It combines a Tree with Checkbox Group: every row has a checkbox, and every parent row can select everything inside it.

Anatomy
| # | Part | Description |
|---|---|---|
| 1 | Chevron | Opens and closes the group. Points right when closed, down when open. Its label is read by screen readers. |
| 2 | Parent checkbox | CheckboxTree.CollapsibleTrigger. Selects or clears everything in the group, shown or not. Indeterminate when some items are selected. |
| 3 | Item | CheckboxTree.Item, with a value. Its text sits next to the checkbox. |
| 4 | Count (add-on) | A Badge you add to a collapsed parent, such as "2 of 3". |
| 5 | Icon (add-on) | An optional Icon before the text, for the type of item. |
Use it when
- Items sit in two or more levels that need to collapse, such as subjects and their assessments.
- People filter by category and sub-category at once.
Don't use it when
- The list is flat, such as five classes. Use Checkbox Group.
- There's only one level with a select all. Use Checkbox Group with
CheckboxGroup.AllItem. - People pick a single item. Use a tree without checkboxes, or Radio Button.
Behaviour
Clicking a parent's checkbox or its text selects it. Clicking the chevron opens or closes it.
A parent selects all its items even when it's closed and they're hidden. Pressing Escape inside an open group closes it and moves focus to its chevron.
Open or closed
Start with groups closed, so people can scan the top level. Open a group by default only when it's the only one, or when it already has selected items.
Hidden selections
When a closed group has selected items, show how many next to it, with a Badge such as "2 of 3". People can then see what's selected without opening every group.
Labels
Keep labels short enough to fit on one line, such as "Year 7 Maths · Autumn". Long labels are cut off with an ellipsis.
Add-ons
These aren't part of the component, but work well with it:
- Search. A Search Input above the tree, for long lists.
- Counts. A Badge on collapsed parents, showing how many items are selected.
- Icons. An Icon before the text, for the type of node.

Keyboard
Tab moves through the chevrons and checkboxes in order. Enter or Space on a chevron opens or closes its group; Space on a checkbox ticks or unticks it. Escape closes the open group you're in.
Accessibility
- Label every chevron. Give
CollapsibleTriggeralabelsuch as "Show Maths assessments", and atitlefor its checkbox, such as "All Maths assessments". - Name every item. Give each item a
titlewith its text, or it's named by itsvalue. - Show hidden selections in text. Use a count Badge on closed groups, not colour alone.
Do's and Don'ts

Do
Show how many items are selected in a closed group.

Don't
Leave a closed group with no hint of what’s selected inside it.

Do
Use a tree for real levels, such as subjects and their assessments.

Don't
Use a tree for a flat list, such as five classes. Use Checkbox Group.

Do
Start with groups closed, so people can scan the top level.

Don't
Open every level of a long tree by default.

Do
Keep labels short enough to fit on one line.

Don't
Use long labels that get cut off.
Structure and spacing
| Property | Token | px | rem |
|---|---|---|---|
| Row height (minimum) | size-8 | 32px | 2 |
| Indent per level | space-4 | 16px | 1 |
| Space for chevron | space-10 | 40px | 2.5 |
| Checkbox to text | space-2 | 8px | 0.5 |
Options
| Option | In code | Values | Default |
|---|---|---|---|
| Selected items | checked, defaultChecked | A list of item values | None |
| On change | onCheckedChange | Called with the new list of values | None |
| Group | CheckboxTree.Collapsible | defaultOpen, open to set its state | Closed |
| Parent row | CheckboxTree.CollapsibleTrigger | label (chevron), title (checkbox) | - |
| Group content | CheckboxTree.CollapsibleContent | The group's items and sub-groups | - |
| Item | CheckboxTree.Item | value, title, disabled | - |