Trees

Trees

A tree is visualization of a structure hierarchy. A branch can be expanded or collapsed.

BaseNot Compatible with S1 Mobile

Preview

No content has been added for this component.

No content has been added for this component.

About Trees

A tree is composed of two core elements .slds-tree and .slds-tree__item. The tree wrapper, the outer most parent ul, will receive the class .slds-tree. This class will be used for scoping a tree, which allows for particular styling based on states in which the tree may enter.

A tree will need helper classes added and removed to help structure the layout. Each child node list needs an aria-level attribute with its value being the number of levels deep it is nested to indicate the distinct grouping is nested within.

Whenever the tree has a nested group, the li element should receive the ARIA role group. This will add appropiate styling to decendent .slds-tree__item elements. A helper class of .slds-is-expanded and .slds-is-collapsed will need to be toggled on the appropriate child of list item node if the decendent groups are visible or not visible.

A .slds-tree__item is any element of the tree that is a single node within a node with an ARIA attribute of role="group". To achieve interactions demostrated in the demo, some helper classes are being added and removed based on actions to the list item node. To achieve the desired hover and focus states, applying the .slds-is-hovered and .slds-is-focused class helpers to the li on its respective interactions. If an item is selected and want to demostrate that state, applying the .slds-is-selected helper class will give you this outcome.

In our example, we are using a chevron icon on tree branches to help indicate to the user what action clicking the tree branch will perform, whether opening or closing it. The effect of rotating the icon 90° to indicate open/closed status is achieved by applying the ARIA attribute aria-controls to the button the icon is contained within. The value of the aria-controls attribute should be the ID of the group that clicking the button will affect.


Overview of CSS Classes

Selector.slds-tree_container
Summary
Supportdev-ready
Restrictdiv
VariantTrue
Selector.slds-tree
Summary
Restrict.slds-tree_container ul, table
Selector.slds-tree__item
Summary
Restrict.slds-tree div, .slds-tree th
Selector.slds-is-disabled
Summary

When a branch doesn't have children, apply slds-is-disabled to the button icon

Restrict.slds-tree__item button
ModifierTrue
Selector.slds-is-hovered
Summary

Hover state for a tree item

Restrict.slds-tree__item
ModifierTrue
Selector.slds-is-selected
Summary

Selected state for a tree item

Restrict.slds-tree__item
ModifierTrue
Selector.slds-is-focused
Summary

Focus state for a tree item

Restrict.slds-tree__item
ModifierTrue
Selector.slds-table_tree
Summary
Restrict.slds-tree
VariantTrue
Selector.slds-table_tree__toggle
Summary
Restrict.slds-table_tree button