Moey Icons
No results. Try “dialog”, “dark” or “grid”.
Moey extras

Tree view

Folders and files, categories, permissions. Plain nested lists — folders are native <details>, so they open and close even without JavaScript.

  • src
    • components3
  • public
<ul class="tree" aria-label="Files">
  <li>
    <details open>
      <summary>
        <i class="mi mi-folder"></i>
        <span class="tree-label">src</span>
      </summary>
      <ul>
        <li>
          <button>
            <i class="mi mi-file-code"></i>
            <span class="tree-label">index.html</span>
          </button>
        </li>
        …
      </ul>
    </details>
  </li>
  <li>
    <button>
      <i class="mi mi-file-text"></i>
      <span class="tree-label">README.md</span>
    </button>
  </li>
</ul>
  • Keyboard: Tab into the tree once, then ↑ ↓ to move, → to open a folder or step inside, ← to close it or step out, Home / End, * opens all folders at that level, and typing a name jumps to it.
  • Selection: click or Space selects a row (aria-selected, moey:select). data-moey-select="multiple" adds Ctrl/⌘-click; "none" turns it off.
  • Folder icons (mi-folder) switch to mi-folder-open by themselves. Screen readers hear a real tree: levels, open / closed, selected.

Leaves can be links — mark the current page with aria-current="page". .tree-lines draws guide lines.

<ul class="tree tree-lines" data-moey-select="none">
  <li><details open><summary>Getting started</summary><ul>
    <li><a href="/docs/install">Installation</a></li>
    <li><a href="/docs/start" aria-current="page">Quick start</a></li>
  </ul></details></li>
</ul>

Checkboxes

Rows can be checkbox labels. Checking a folder checks everything inside; a folder with only some boxes checked shows a dash. The boxes are real inputs, so the form sends what's checked.

Role: Support
  • Orders
  • Products
  • Settings
<ul class="tree" data-moey-select="none">
  <li><details open>
    <summary><label onclick="event.stopPropagation()"><input type="checkbox" class="form-check-input"></label>Orders</summary>
    <ul>
      <li>
        <label><input type="checkbox" class="form-check-input" name="perm" value="orders.view"> View orders</label>
      </li>
      <li>
        <label><input type="checkbox" class="form-check-input" name="perm" value="orders.edit"> Edit orders</label>
      </li>
    </ul>
  </details></li>
</ul>

Filter

Point any input at the tree with data-moey-filter="#id". Matches stay, with the folders around them opened; clear it and everything is back as it was.

  • src
    • components
    • pages
  • docs
<input type="search" placeholder="Filter files" data-moey-filter="#files">
<ul class="tree" id="files">…</ul>

Loading children

Big trees can load a folder when it opens: listen for moey:toggle, add the children, call Moey.tree(tree). details.is-loading shows a spinner meanwhile.

  • Lisbon
    • Porto
      tree.addEventListener('moey:toggle', async (e) => {
        const folder = e.detail.item.parentElement;          // the <details>
        if (!e.detail.open || folder.dataset.loaded) return;
        folder.classList.add('is-loading');
        const items = await fetch('/api/children?id=' + folder.dataset.id).then((r) => r.json());
        folder.querySelector('ul').innerHTML = items.map((i) => `<li><button>${i.name}</button></li>`).join('');
        folder.classList.remove('is-loading');
        folder.dataset.loaded = '1';
        Moey.tree(tree);                                    // roles & keys for the new rows
      });

      Compact and colored

      .tree-sm for dense sidebars; theme-<color> colors the selection.

      • Inbox
      • Archive
      • Catalog
      • Drafts
      <ul class="tree tree-sm theme-purple">…</ul>
      <ul class="tree theme-green">…</ul>
      Class / attributeWhat it does
      .treeOn the outer <ul>. Folders: <li><details><summary> + a nested <ul>. Leaves: <a>, <button>, <label> or .tree-item
      .tree-label · .tree-metaThe name (truncates) · a count or size on the right
      data-moey-select"multiple" (Ctrl/⌘-click) or "none" — single by default
      data-moey-filter="#tree"On an input: filters the tree as you type
      .tree-lines · .tree-sm · theme-<color>Guide lines · compact · selection color
      details.is-loadingA spinner instead of the chevron while children load
      Eventsmoey:select (detail.item, detail.selected) · moey:toggle (detail.item, detail.open)
      Moey.tree(tree) · Moey.tree(tree, 'expand' | 'collapse')Refresh after adding rows · open / close every folder