Surfaces and display
Tree
Nested items that open and close: folders, a document's parts, an organisation. <kui-tree> gives a ul.kui-tree[role="tree"] the keys of the WAI-ARIA tree view.
Examples
The files of a case
Focus the tree and use the arrows: Right opens a folder, Left closes it or goes to its parent, Enter selects. Type a letter to jump.
-
Podnesci
- Tužba.pdf
- Odgovor na tužbu.pdf
-
Dokazi
- Fotografije oštećenja.zip
-
Veštačenje
- Nalaz veštaka.pdf
- Punomoćje.pdf
HTML
<kui-tree>
<ul class="kui-tree" role="tree" aria-label="Files of case P-1423/2026">
<li role="treeitem" aria-expanded="true">
<div class="kui-tree__row"><span class="kui-tree__twist"></span><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#folder-open"></use></svg><span id="tree-l1">Podnesci</span></div>
<ul role="group">
<li role="treeitem" aria-selected="true"><div class="kui-tree__row"><span class="kui-tree__twist"></span><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#file-text"></use></svg><span>Tužba.pdf</span></div></li>
<li role="treeitem"><div class="kui-tree__row"><span class="kui-tree__twist"></span><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#file-text"></use></svg><span>Odgovor na tužbu.pdf</span></div></li>
</ul>
</li>
<li role="treeitem" aria-expanded="false">
<div class="kui-tree__row"><span class="kui-tree__twist"></span><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#folder"></use></svg><span id="tree-l2">Dokazi</span></div>
<ul role="group">
<li role="treeitem"><div class="kui-tree__row"><span class="kui-tree__twist"></span><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#image"></use></svg><span>Fotografije oštećenja.zip</span></div></li>
<li role="treeitem" aria-expanded="false">
<div class="kui-tree__row"><span class="kui-tree__twist"></span><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#folder"></use></svg><span id="tree-l3">Veštačenje</span></div>
<ul role="group">
<li role="treeitem"><div class="kui-tree__row"><span class="kui-tree__twist"></span><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#file-text"></use></svg><span>Nalaz veštaka.pdf</span></div></li>
</ul>
</li>
</ul>
</li>
<li role="treeitem"><div class="kui-tree__row"><span class="kui-tree__twist"></span><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#file"></use></svg><span>Punomoćje.pdf</span></div></li>
</ul>
</kui-tree>
States
Every state
Selected: the accent fill and stronger text (aria-selected="true"). Focused: the ring inside the row. Hover: a soft fill. Closed branch: the arrow points right and its children are hidden; open: it points down. A long name wraps in its row.
- Selected
- Closed branch
- Child
- Jahresabschlussprüfungsbericht der Wirtschaftsprüfungsgesellschaft 2025.pdf
HTML
<kui-tree>
<ul class="kui-tree" role="tree" aria-label="States">
<li role="treeitem" aria-selected="true"><div class="kui-tree__row"><span class="kui-tree__twist"></span><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#file"></use></svg><span>Selected</span></div></li>
<li role="treeitem" aria-expanded="false"><div class="kui-tree__row"><span class="kui-tree__twist"></span><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#folder"></use></svg><span id="tree-s2">Closed branch</span></div><ul role="group"><li role="treeitem"><div class="kui-tree__row"><span class="kui-tree__twist"></span><span>Child</span></div></li></ul></li>
<li role="treeitem"><div class="kui-tree__row"><span class="kui-tree__twist"></span><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#file"></use></svg><span>Jahresabschlussprüfungsbericht der Wirtschaftsprüfungsgesellschaft 2025.pdf</span></div></li>
</ul>
</kui-tree>
Classes and attributes
kui-tree- The element that adds the keys and the selection.
ul.kui-tree[role="tree"]- The tree; give it an aria-label.
li[role="treeitem"]- An item. aria-selected="true" on the selected one.
aria-expanded- On a branch: true or false. Its children are in a ul[role="group"].
.kui-tree__row, .kui-tree__twist- The visible row, and the space for the arrow (drawn on branches only).
kui-select- Event when an item is selected; detail.item.
Keyboard
- Arrow Down or Arrow Up
- Moves to the next or previous visible item.
- Arrow Right
- Opens a closed branch; on an open one, moves to its first child.
- Arrow Left
- Closes an open branch; otherwise moves to the parent.
- Home or End
- Moves to the first or last visible item.
- Enter or Space
- Selects the item.
- A letter
- Moves to the next item that starts with it.
- *
- Opens every branch at the same level.
Accessibility
- Follows the WAI-ARIA tree view pattern: one item is in the tab order, the arrows move.
- A branch says whether it is expanded; a screen reader also says its level and position.
- Icons are aria-hidden; the name is the text of the row.
- Use a tree only when the nesting matters; a flat list is easier to use.
Do and do not
Do
- Open the branch that holds the selected item.
- Keep names short; put details in the panel the item opens.
- Sort folders before files.
Do not
- Do not nest deeper than four levels.
- Do not use a tree for the main navigation of a site.
- Do not put buttons inside tree rows.