Dropdown menu
Menus with icons, shortcuts, descriptions, submenus, checkbox and radio items, full keyboard control and typeahead — opening upward when there's no room, and as a context menu at the pointer.
Actions · shortcuts · a submenu · danger
grid on · ruler off · comfortable
Context menu · right-click (or the menu key) in the box
🖱️ Right-click anywhere in heresorted by date
Keyboard: Enter / ↓ opens · ↑ ↓ Home End · type a letter to jump · → opens a submenu, ← closes it · Esc
Usage
import { signal } from "./index.js";import { Menu, ContextMenu } from "./components/menu.js"; Menu({ label: "Actions", items: [ { label: "Edit", icon: "✎", shortcut: "⌘E", onClick: edit }, { label: "Duplicate", description: "A copy in the same folder", onClick: dup }, { label: "Move to", items: [{ label: "Archive", onClick: archive }] }, // a submenu { divider: true }, { label: "Delete", danger: true, onClick: remove },] }) // items that remember: checkbox (a boolean signal) and radio (a group signal) — the menu stays openMenu({ label: "View", items: [ { group: "Show" }, { label: "Grid lines", type: "checkbox", checked: grid }, { group: "Density" }, { label: "Compact", type: "radio", value: "compact", group: density },] }) // the same menu at the pointerContextMenu({ items, children: html`<div>Right-click me</div>` })