Read This First
No ARIA is better than Bad ARIA. Before using any ARIA, read this to understand why.
How to build accessibility semantics into web patterns and widgets
No ARIA is better than Bad ARIA. Before using any ARIA, read this to understand why.
A tree view widget presents a hierarchical list. Any item in the hierarchy may have child items, and items that have children may be expanded or collapsed to show or hide the children. For example, in a file system navigator that uses a tree view to display folders and files, an item representing a folder can be expanded to reveal the contents of the folder, which may be files, folders, or both.
When using a keyboard to navigate a tree, a visual keyboard indicator informs the user which item is focused. If the tree allows the user to choose just one item for an action, then it is known as a single-select tree. In some implementations of single-select tree, the focused item also has a selected state; this is known as selection follows focus. However, in multi-select trees, which enable the user to select more than one item for an action, the selected state is always independent of the focus. For example, in a typical file system navigator, the user can move focus to select any number of files for an action, such as copy or move. It is important that the visual design distinguish between items that are selected and the item that has focus. For more details, see this description of differences between focus and selection and Deciding When to Make Selection Automatically Follow Focus.
aria-level
, aria-posinset
and aria-setsize
based on DOM structure.aria-level
, aria-posinset
and aria-setsize
.aria-level
, aria-posinset
and aria-setsize
based on DOM structure.Terms for describing tree views include:
For a vertically oriented tree:
tree
role supports the aria-activedescendant property, which provides an alternative to moving DOM focus among treeitem
elements when implementing keyboard navigation.
For details, see Managing Focus in Composites Using aria-activedescendant.
tree
or referenced by an aria-owns property set on the tree
element.treeitem
that serves as a parent node has aria-expanded set to false
when the node is in a closed state and set to true
when the node is in an open state.
End nodes do not have the aria-expanded
attribute because, if they were to have it, they would be incorrectly described to assistive technologies as parent nodes.
tree
has aria-multiselectable set to true
.
Otherwise, aria-multiselectable
is either set to false
or the default value of false
is implied.
aria-selected
, then aria-checked
is not specified for any nodes.
Alternatively, if the selection state is indicated with aria-checked
, then aria-selected
is not specified for any nodes.
See notes below regarding considerations for which property to use and for details of the unusual conditions that might allow for both properties in the same tree.
true
.
No more than one node is selected at a time if the element with role tree
does not have aria-multiselectable set to true
.
false
.tree
has either a visible label referenced by aria-labelledby or a value specified for aria-label.tree
element is horizontally oriented, it has aria-orientation set to horizontal
.
The default value of aria-orientation
for a tree is vertical
.
aria-selected
or aria-checked
are:
aria-selected
for single-select widgets and aria-checked
for multi-select widgets.
In the absence of factors that would make an alternative convention more appropriate, this is a recommended convention.
selectitems? Or, is the visual indicator of selection a check mark?
aria-selected
and aria-checked
are extremely rare.
It is strongly recommended to avoid designing a tree widget that would have the need for more than one type of state.
If both states were to be used within a tree, all the following conditions need to be satisfied:
aria-selected
is different from the meaning and purpose of aria-checked
in the user interface.This is an unpublished draft preview that might include content that is not yet approved. The published website is at w3.org/WAI/.