Veylo Docs

HomeDocsOverlays and menus

Overlays and menus

Confirm

!Delete 3 files? This cannot be undone.
<button data-veylo-modal="#dlg">Open</button>
<dialog class="veylo-dialog" id="dlg">
  <h1 class="veylo-title"><span>Confirm</span></h1>
  <div class="veylo-body">
    <div class="msg"><span class="ico no">!</span><span>Delete 3 files?</span></div>
    <div class="btns">
      <button class="danger def" data-veylo-close>Delete</button>
      <button data-veylo-close>Cancel</button>
    </div>
  </div>
</dialog>

Uses the native dialog element. data-veylo-modal="#id" opens it as a modal. data-veylo-close on any button inside closes it. Behaviour added by veylo.js:

  • Click on the backdrop closes it, unless the dialog has data-veylo-static.
  • Esc closes it.
  • Enter in a text field triggers the .def button.
  • Focus goes to the first control and returns to the opener after closing.

Layout parts: .msg is an icon and message row (.ico with no, ok, err or none), .btns is the right-aligned button row. A dialog without script can be opened with el.showModal().

  • Cut
  • Copy
  • Delete
  • Word wrap
  • Encoding
  • Hot item
<ul class="veylo-popup">
  <li data-k="Ctrl+X">Cu<u>t</u></li>
  <li class="dis" data-k="Del">Delete</li>
  <li class="sep"></li>
  <li class="chk">Word wrap</li>
  <li class="sub">Encoding</li>
</ul>
ItemMeaning
data-kShortcut label, right-aligned
<u>x</u>Access key: pressing that letter picks the item
sepSeparator line
disDisabled, skipped by keys
chkChecked item (tick drawn in CSS); toggle it in your script
subHas a submenu (arrow drawn in CSS)
hotHighlighted item

Menu keys: Up and Down move, Home and End jump, Enter picks, Esc closes. A pick fires veylo-pick on the menu with detail.item.

Dropdown ▾
  • New
  • Open...
  • Exit
Account ▾
  • Profile
  • Settings
  • Sign out
<details class="veylo-dd btn">
  <summary>File</summary>
  <ul class="veylo-popup"><li>New</li><li>Open...</li></ul>
</details>

Built on details, so it opens without script. veylo.js adds click-away and Esc closing, closing when you pick an item, closing when another dropdown opens, and arrow-key navigation. Add btn to draw the summary as a button.

Context menu

Right-click here, or focus this box and press Shift+F10.
  • Cut
  • Copy
  • Paste
  • Rename
<div data-veylo-context="#ctx" tabindex="0">Right-click me</div>
<ul class="veylo-popup" id="ctx"><li>Cut</li><li>Copy</li></ul>
<script>
  document.getElementById('ctx').addEventListener('veylo-pick', function (e) {
    console.log(e.detail.item.textContent);
  });
</script>

The menu opens at the pointer and stays on screen. Click away, Esc, scrolling or resizing closes it. The right-click menu key and Shift+F10 also work.

Tooltips

Use data-tip (see Feedback).