Tree Grid
- HTML/CSS:Dev Ready
- Web Component:True
- Layout:Desktop Only
Sections
- About Tree Grid
- Base
- Examples
- Headless
- Headless with selected row
- Headless with no borders
- Headless with no borders and a selected row
- Single select
- Single select with a selected row
- Single select headless
- Single select headless with selected row
- Single select headless with no borders
- Single select headless with no borders and a selected row
- Modifiers
- Overview of CSS Classes
Choose a row | Sort by: Account Name | Sort by: Employees | Sort by: Phone Number | Sort by: Account Owner | Sort by: Billing City | Actions |
---|---|---|---|---|---|---|
3,100 | 837-555-1212 | Phoenix, AZ | ||||
10,000 | 837-555-1212 | San Francisco, CA | ||||
6,000 | 837-555-1212 | New York, NY | ||||
1,234 | 837-555-1212 | Paris, France |
About Tree Grid#
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#
Markup#
role="treegrid"
should be applied to thetable
elementaria-readonly="true"
should be applied to thetable
elementaria-level="n"
wheren
represents the nesting level of a particular grid row, should be applied to thetr
elementaria-setsize="n"
wheren
is the number of items for that specificaria-level
should be applied to thetr
elementaria-posinset="n"
wheren
represents the position in thearia-level
set the row is placed at, should be applied to thetr
elementaria-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 firsttr
in 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 thetable
elementaria-selected="false"
should be set by default on alltr
elements that aren't selectedaria-selected="true"
should be set only on thetr
elements that are selected
Single Select tree grid:
aria-selected="true"
should be applied to thetr
that is selected in the tree grid
Keyboard Interactions#
- 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
tr
or thetd
- Actionable mode is enabled when the user presses the
Enter
key, where actionable elements become focusable in the cell - Actionable mode is exited when the user presses the
Escape
key, 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
Down
arrow key moves the user down one row and movestabindex="0"
with itUp
arrow key moves the user up one row and movestabindex="0"
with itSpace
key when focused on a row should select that row by settingaria-selected="true
on thetr
elementRight
arrow key on a collapsed row, will expand it and updatearia-expanded
Right
arrow key on an expanded or end row will move the user to the first cell in the row and movetabindex="0"
with itRight
arrow key on a cell will move the user to the next cell in the row and movetabindex="0"
with itLeft
arrow key on a collapsed or end row will move the user to it's parent row and collapse it, if it has oneLeft
arrow key on an expanded row will collapse it and updatearia-expanded
Left
arrow key on a cell will move the user to the previous cell in the row and movestabindex="0"
with itLeft
arrow key on the first cell of a row will move the user back to the row and movestabindex="0"
with it
Base#
Choose a row | Sort by: Account Name | Sort by: Employees | Sort by: Phone Number | Sort by: Account Owner | Sort by: Billing City | Actions |
---|---|---|---|---|---|---|
3,100 | 837-555-1212 | Phoenix, AZ | ||||
10,000 | 837-555-1212 | San Francisco, CA | ||||
6,000 | 837-555-1212 | New York, NY | ||||
1,234 | 837-555-1212 | Paris, France |
<table aria-multiselectable="true" class="slds-table slds-table_bordered slds-table_edit slds-table_fixed-layout slds-table_resizable-cols slds-tree slds-table_tree" role="treegrid" aria-label="Example default tree grid">
<thead>
<tr class="slds-line-height_reset">
<th class="slds-text-align_right" scope="col" style="width:3.25rem">
States#
Expanded#
Choose a row | Sort by: Account Name | Sort by: Employees | Sort by: Phone Number | Sort by: Account Owner | Sort by: Billing City | Actions |
---|---|---|---|---|---|---|
3,100 | 837-555-1212 | Phoenix, AZ | ||||
10,000 | 837-555-1212 | San Francisco, CA | ||||
745 | 837-555-1212 | New York, NY | ||||
6,000 | 837-555-1212 | New York, NY | ||||
1,234 | 837-555-1212 | Paris, France |
<table aria-multiselectable="true" class="slds-table slds-table_bordered slds-table_edit slds-table_fixed-layout slds-table_resizable-cols slds-tree slds-table_tree" role="treegrid" aria-label="Example expanded tree grid">
<thead>
<tr class="slds-line-height_reset">
<th class="slds-text-align_right" scope="col" style="width:3.25rem">
Selected row#
Choose a row | Sort by: Account Name | Sort by: Employees | Sort by: Phone Number | Sort by: Account Owner | Sort by: Billing City | Actions |
---|---|---|---|---|---|---|
3,100 | 837-555-1212 | Phoenix, AZ | ||||
10,000 | 837-555-1212 | San Francisco, CA | ||||
745 | 837-555-1212 | New York, NY | ||||
6,000 | 837-555-1212 | New York, NY | ||||
1,234 | 837-555-1212 | Paris, France |
<table aria-multiselectable="true" class="slds-table slds-table_bordered slds-table_edit slds-table_fixed-layout slds-table_resizable-cols slds-tree slds-table_tree" role="treegrid" aria-label="Example tree grid with selected row">
<thead>
<tr class="slds-line-height_reset">
<th class="slds-text-align_right" scope="col" style="width:3.25rem">
Deeply nested branches#
Choose a row | Sort by: Account Name | Sort by: Employees | Sort by: Phone Number | Sort by: Account Owner | Sort by: Billing City | Actions |
---|---|---|---|---|---|---|
3,100 | 837-555-1212 | Phoenix, AZ | ||||
10,000 | 837-555-1212 | San Francisco, CA | ||||
3,000 | 837-555-1212 | New York, NY | ||||
745 | 837-555-1212 | New York, NY | ||||
578 | 837-555-1212 | Los Angeles, CA | ||||
430 | 837-555-1212 | San Francisco, CA | ||||
1,210 | 837-555-1212 | New York, NY | ||||
410 | 837-555-1212 | New York, NY | ||||
390 | 837-555-1212 | Los Angeles, CA | ||||
270 | 837-555-1212 | San Francisco, CA | ||||
6,000 | 837-555-1212 | New York, NY | ||||
2,540 | 837-555-1212 | New York, NY | ||||
1,856 | 837-555-1212 | New York, NY | ||||
1,934 | 837-555-1212 | Los Angeles, CA |
<table aria-multiselectable="true" class="slds-table slds-table_bordered slds-table_edit slds-table_fixed-layout slds-table_resizable-cols slds-tree slds-table_tree" role="treegrid" aria-label="Example tree grid with deep nesting">
<thead>
<tr class="slds-line-height_reset">
<th class="slds-text-align_right" scope="col" style="width:3.25rem">
Examples#
Headless#
Choose a row to select | Account Name | Actions |
---|---|---|
<table aria-multiselectable="true" class="slds-table slds-table_header-hidden slds-table_bordered slds-table_edit slds-tree slds-table_tree" role="treegrid" aria-label="Example headless tree grid">
<thead class="slds-assistive-text">
<tr class="slds-line-height_reset">
<th class="slds-text-align_right" scope="col" style="width:3.25rem">
Headless with selected row#
Choose a row to select | Account Name | Actions |
---|---|---|
<table aria-multiselectable="true" class="slds-table slds-table_header-hidden slds-table_bordered slds-table_edit slds-tree slds-table_tree" role="treegrid" aria-label="Example headless tree grid with selected row">
<thead class="slds-assistive-text">
<tr class="slds-line-height_reset">
<th class="slds-text-align_right" scope="col" style="width:3.25rem">
Headless with no borders#
Choose a row to select | Account Name | Actions |
---|---|---|
<table aria-multiselectable="true" class="slds-table slds-table_header-hidden slds-table_edit slds-tree slds-table_tree" role="treegrid" aria-label="Example headless border-less tree grid">
<thead class="slds-assistive-text">
<tr class="slds-line-height_reset">
<th class="slds-text-align_right" scope="col" style="width:3.25rem">
Headless with no borders and a selected row#
Choose a row to select | Account Name | Actions |
---|---|---|
<table aria-multiselectable="true" class="slds-table slds-table_header-hidden slds-table_edit slds-tree slds-table_tree" role="treegrid" aria-label="Example headless border-less tree grid with selected row">
<thead class="slds-assistive-text">
<tr class="slds-line-height_reset">
<th class="slds-text-align_right" scope="col" style="width:3.25rem">
Single select#
Sort by: Account Name | Sort by: Employees | Sort by: Phone Number | Sort by: Account Owner | Sort by: Billing City | Actions |
---|---|---|---|---|---|
3,100 | 837-555-1212 | Phoenix, AZ | |||
10,000 | 837-555-1212 | San Francisco, CA | |||
6,000 | 837-555-1212 | New York, NY | |||
1,234 | 837-555-1212 | Paris, France |
<table class="slds-table slds-table_bordered slds-table_edit slds-table_fixed-layout slds-table_resizable-cols slds-tree slds-table_tree" role="treegrid" aria-label="Example single select tree grid">
<thead>
<tr class="slds-line-height_reset">
<th aria-label="Account Name" aria-sort="none" class="slds-has-button-menu slds-is-resizable slds-is-sortable" scope="col">
Single select with a selected row#
Sort by: Account Name | Sort by: Employees | Sort by: Phone Number | Sort by: Account Owner | Sort by: Billing City | Actions |
---|---|---|---|---|---|
3,100 | 837-555-1212 | Phoenix, AZ | |||
10,000 | 837-555-1212 | San Francisco, CA | |||
6,000 | 837-555-1212 | New York, NY | |||
1,234 | 837-555-1212 | Paris, France |
<table class="slds-table slds-table_bordered slds-table_edit slds-table_fixed-layout slds-table_resizable-cols slds-tree slds-table_tree" role="treegrid" aria-label="Example single select tree grid with selected row">
<thead>
<tr class="slds-line-height_reset">
<th aria-label="Account Name" aria-sort="none" class="slds-has-button-menu slds-is-resizable slds-is-sortable" scope="col">
Single select headless#
Account Name | Actions |
---|---|
<table class="slds-table slds-table_header-hidden slds-table_bordered slds-table_edit slds-tree slds-table_tree" role="treegrid" aria-label="Example headless single select tree grid">
<thead class="slds-assistive-text">
<tr class="slds-line-height_reset">
<th aria-label="Account Name" class="" scope="col">
Single select headless with selected row#
Account Name | Actions |
---|---|
<table class="slds-table slds-table_header-hidden slds-table_bordered slds-table_edit slds-tree slds-table_tree" role="treegrid" aria-label="Example single select tree grid with selected row">
<thead class="slds-assistive-text">
<tr class="slds-line-height_reset">
<th aria-label="Account Name" class="" scope="col">
Single select headless with no borders#
Account Name | Actions |
---|---|
<table class="slds-table slds-table_header-hidden slds-table_edit slds-tree slds-table_tree" role="treegrid" aria-label="Example headless border-less single select tree grid">
<thead class="slds-assistive-text">
<tr class="slds-line-height_reset">
<th aria-label="Account Name" class="" scope="col">
Single select headless with no borders and a selected row#
Account Name | Actions |
---|---|
<table class="slds-table slds-table_header-hidden slds-table_edit slds-tree slds-table_tree" role="treegrid" aria-label="Example headless border-less single select tree grid with selected row">
<thead class="slds-assistive-text">
<tr class="slds-line-height_reset">
<th aria-label="Account Name" class="" scope="col">
Modifiers#
Interaction#
Item Disabled#
When a branch doesn't have children, apply slds-is-disabled
to the corresponding slds-button_icon
element.
Choose a row | Sort by: Account Name | Sort by: Employees | Sort by: Phone Number | Sort by: Account Owner | Sort by: Billing City | Actions |
---|---|---|---|---|---|---|
3,100 | 837-555-1212 | Phoenix, AZ | ||||
10,000 | 837-555-1212 | San Francisco, CA | ||||
6,000 | 837-555-1212 | New York, NY | ||||
1,234 | 837-555-1212 | Paris, France |
<table aria-multiselectable="true" class="slds-table slds-table_bordered slds-table_edit slds-table_fixed-layout slds-table_resizable-cols slds-tree slds-table_tree" role="treegrid" aria-label="Example tree grid with disabled item">
<thead>
<tr class="slds-line-height_reset">
<th class="slds-text-align_right" scope="col" style="width:3.25rem">
Item Hovered#
When a tree item is hovered, apply slds-is-hovered
to slds-tree__item
element`.
Choose a row | Sort by: Account Name | Sort by: Employees | Sort by: Phone Number | Sort by: Account Owner | Sort by: Billing City | Actions |
---|---|---|---|---|---|---|
3,100 | 837-555-1212 | Phoenix, AZ | ||||
10,000 | 837-555-1212 | San Francisco, CA | ||||
6,000 | 837-555-1212 | New York, NY |
<table aria-multiselectable="true" class="slds-table slds-table_bordered slds-table_edit slds-table_fixed-layout slds-table_resizable-cols slds-tree slds-table_tree" role="treegrid" aria-label="Example tree grid with hovered item">
<thead>
<tr class="slds-line-height_reset">
<th class="slds-text-align_right" scope="col" style="width:3.25rem">
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 | |
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-disabled Deprecated |
---|---|
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-is-selected Deprecated |
---|---|
Summary | Selected state for a tree item |
Restrict | .slds-tree__item |
Selector | .slds-is-focused Deprecated |
---|---|
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-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 |
Tree Grid Release Notes
2.7.0
Added
- Checkboxes in the left most column were added to multi select tree grids
- Multi select tree grids now require
aria-multiselectable="true"
applied to thetable
element. - Multi select tree grids now require
aria-selected
to be set tofalse
on every row that is not selected - Single select tree grids were added as examples
- Headless tree grids were added
- Borderless tree grids were added
Changed
- Tree grid now aligns better with the lightning component, which is an extension of Advanced Data Table.