Skip to the page
TACTILE UI

Kit part · File trees

File tree

Folders and files as a real tree, printed like a wiring diagram: traces with an elbow into every item, chevrons that turn, and the chosen file set in a recess with its lamp lit. Written as a plain nested list.

Element
<tui-file-tree>
Needs
kit.css + kit.mjs
Rules
file-tree.rules.md · 5
Finishes
Aluminium · Graphite · Porcelain · Black
Volumes
Tactile · Quiet
On this page
  1. Variants
  2. Every state, at once
  3. API
  4. Markup
  5. Accessibility
  6. How it’s built
  7. Rules
  8. Related parts
01

Variants

  • kit
    • kit.css
  • lab
    • kit-check.mjs
  • test
    • kit-docs.test.mjs
  • README.md
Folders closed
  • reels
    • reel-01.wav
    • reel-02.wav
    • reel-03.wav
With meta
02

Every state, at once

Both finishes, side by side. Hover, pressed and focus are forced with .is-hover, .is-down and .is-focus; checked and disabled are real.

Aluminium

PartRestHoverFocusChosen
File
  • kit.css96 KB
  • kit.css96 KB
  • kit.css96 KB
  • kit.css96 KB
Folder
  • parts
  • parts

Graphite

PartRestHoverFocusChosen
File
  • kit.css96 KB
  • kit.css96 KB
  • kit.css96 KB
  • kit.css96 KB
Folder
  • parts
  • parts
03

API

NameKindValuesWhat it does
labelattributerequiredNames the tree (aria-label on the role="tree" list).
ul > limarkupnestedAn item. Its text before any nested <ul> is its name; an <li> holding a <ul> is a folder.
data-openattributeon a folder <li>Starts open. Folders on the path to the chosen item open anyway.
aria-selected="true"attributeon one <li>The chosen item: a recess with its lamp lit, and the tab stop.
data-metaattributetextA short fact at the row’s end: a size, a count.
valueproperty"kit/parts/calendar.mjs"The chosen item’s path, names joined by “/”.
changeeventbubblesA different item was chosen.
--tui-traceCSS propertyink-3 at 55%The colour of the printed guides.
ArrowDown · ArrowUpkeyboard—Next and previous visible item.
ArrowRight · ArrowLeftkeyboard—Open a folder, then step into it; close it, then step out to its parent.
Home · Endkeyboard—First and last visible item.
Enter · Spacekeyboard—Choose the item; on a folder, also open or close it.
*keyboard—Open every folder beside the focused one.
Letterskeyboardtype-aheadJump to the next item whose name starts with what you typed.
04

Markup

<tui-file-tree label="Project files">
  <ul>
    <li data-open>kit
      <ul>
        <li>brain<ul><li>rules.md</li></ul></li>
        <li data-open>parts
          <ul>
            <li data-meta="6 KB">calendar.css</li>
            <li data-meta="15 KB" aria-selected="true">calendar.mjs</li>
          </ul>
        </li>
        <li data-meta="96 KB">kit.css</li>
      </ul>
    </li>
    <li data-meta="2 KB">README.md</li>
  </ul>
</tui-file-tree>
import '/kit/kit.mjs';   // defines <tui-file-tree>

const tree = document.querySelector('tui-file-tree');
tree.addEventListener('change', () => open(tree.value));   // "kit/parts/calendar.mjs"

Needs kit.css and kit.mjs. How to install the kit.

05

Accessibility

  • The WAI-ARIA tree view pattern: role="tree", treeitem with aria-level, aria-expanded and aria-selected, nested role="group" lists. The part writes all of it from plain markup.
  • One tab stop for the whole tree (roving tabindex); the arrows do the rest. The focus ring draws on the row, not the whole subtree.
  • Chosen is the recess and the lamp as well as aria-selected; folders read as expanded or collapsed.
  • Icons and chevrons are hidden from screen readers; the name is read once.
06

How it’s built

A custom element that reads a nested list and writes the tree roles into it, wrapping each name in a row with a printed chevron, a folder or page mark (SVG masks in currentColor, so they print in either finish), the meta and a lamp. The guides are two hairlines per item (a vertical run on its ::before that stops at the elbow for the last child, and the elbow on the row’s ::before), so they follow the tree as it opens and closes with no drawing code. The chevron turns 90° over 120ms; nothing else moves.

07

Rules

file-tree.rules.mdIn the brain

Write names in nested lists and let the part do the ARIA; open only the path to what matters.

5 rules in this file, with the foundations they rest on and the anti-patterns that break them. Full rules ship in the brain with the Pass.

08

Side rail

App navigation in a panel: the current page is a recess with its lamp lit. The rail on the left of this page is one.

  1. IntroPiano, room mics1:12
  2. LodeFull band4:05
  3. Night reelVocal and tape3:42

List

Rows in a rack: a mark, a title, a second line and a fact or a key at the end. Chosen rows sink into a recess with their check key latched; in a running order, a row lifts out of the rack on its skirt and slides past the others, from the keyboard or by its grip.

Lamp

The only colour in the kit: a lamp that is on. Green is on, amber is waiting, red is recording or failing, blue is linked, white is standing by. Always next to words.

Docs
Finish
Volume