Tree Grid
- HTML/CSS:Dev Ready
- Layout:Desktop Only
A tree is visualization of a structure hierarchy. A branch can be expanded or collapsed.
BaseDesktop Only
Preview
About Base
A tree grid is additional semantics that are laid on top of a grid based component via ARIA attributes, to enable hierarchically structured tabular data. The tree grid comes with a very specific keyboard interaction model which must be implemented for the component to be screen reader accessible.
Accessibility
Notable attributes
role="treegrid"should be applied to thetableelementaria-readonly="true"should be applied to thetableelementaria-level="n"wherenrepresents the nesting level of a particular grid row, should be applied to thetrelementaria-setsize="n"wherenis the number of items for that specificaria-levelshould be applied to thetrelementaria-posinset="n"wherenrepresents the position in thearia-levelset the row is placed at, should be applied to thetrelementaria-expanded="false"should be placed on rows that are collapsed and have child rowsaria-expanded="true"should be placed on rows that are expanded and have child rowstabindex="0"should be placed on the firsttrin the grid on load, to make the row focusable- Every actionable element in the grid should have `tabindex="-1" applied to make them not focusable in the grids navigation mode
Multi select tree grid
aria-multiselectable="true"should be placed on thetableelementaria-selected="false"should be set by default on alltrelements that aren't selected _aria-selected="true"should be set only on thetrelements that are selected
Single Select tree grid
aria-selected="true"should be applied to thetrthat is selected in the tree grid
Keyboard interaction
- Overall keyboard interaction should follow the same keyboard modal as the Advanced and Inline Edit Data Table with some additions
- Navigation mode is the default mode. The grid only has a single focusable element at any time and it is either the
tror thetd - Actionable mode is enabled when the user presses the
Enterkey, where actionable elements become focusable in the cell - Actionable mode is exited when the user presses the
Escapekey, and the user is placed back into Navigation Mode on the last cell they were in
- Navigation mode is the default mode. The grid only has a single focusable element at any time and it is either the
- User focus is initially placed on the first row in the tree grid
Downarrow key moves the user down one row and movestabindex="0"with itUparrow key moves the user up one row and movestabindex="0"with itSpacekey when focused on a row should select that row by settingaria-selected="trueon thetrelementRightarrow key on a collapsed row, will expand it and updatearia-expandedRightarrow key on an expanded or end row will move the user to the first cell in the row and movetabindex="0"with itRightarrow key on a cell will move the user to the next cell in the row and movetabindex="0"with itLeftarrow key on a collapsed or end row will move the user to it's parent row and collapse it, if it has oneLeftarrow key on an expanded row will collapse it and updatearia-expandedLeftarrow key on a cell will move the user to the previous cell in the row and movestabindex="0"with itLeftarrow key on the first cell of a row will move the user back to the row and movestabindex="0"with it
Overview of CSS Classes
- Selector
- The CSS class being referred to.
- Summary
- A description of what the class does.
- Support
- Whether the class name is dev-ready (meaning it's fully vetted and tested and safe to use) or prototype (which means it's not fully vetted yet).
- Restrict
- The selector that the class name is allowed to be used on.
- Variant
- The base level pattern for a component. A variant can be extended to create another variant of that component, for example, a stateful button is a derivative of the base button.
- Modifier
- A single class that can be added to an HTML element of a component to modify its output. Typically these will be colors, sizing and positioning.
| Selector | .slds-table_tree |
|---|---|
| Summary | A tree grid is a way to structure tabular data that has a hierarchical structure. A tree grid row can be expanded or collapsed. |
| Support | dev-ready |
| Restrict | table |
| Variant | True |
| Selector | .slds-tree__item |
|---|---|
| Summary | Initializes a slds tree item |
| Restrict | .slds-table_tree th |
| Selector | .slds-is-selectedDeprecated |
|---|---|
| Summary | Selected state for a tree item |
| Restrict | .slds-tree__item |
| Selector | .slds-is-focusedDeprecated |
|---|---|
| Summary | Focus state for a tree item |
| Restrict | .slds-tree__item |
| Selector | .slds-is-hovered |
|---|---|
| Summary | Hover state for a tree item |
| Restrict | .slds-tree__item |
| Modifier | True |
| 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 |
| Modifier | True |
| Selector | .slds-tree__item-label |
|---|---|
| Summary | The label text of a tree item or tree branch |
| Restrict | .slds-tree__item span |
| Selector | .slds-tree__item-meta |
|---|---|
| Summary | The meta text or secondary text of a tree item |
| Restrict | .slds-tree__item span |