Components/Navigation/Dropdown Menu
COMPONENT37.37

Dropdown Menu

Popover menu with keyboard navigation, submenus and destructive items. Triggers via popovertarget.


INSTALL

1pnpm dlx @sayagodev/mo add dropdown

Or import the files from the package (no copy):

1import "@sayagodev/mo/css/dropdown.css";2import "@sayagodev/mo/css/shared.css";3import "@sayagodev/mo/js/dropdown.js";

EXAMPLES

Demo
My Account





Basic with submenu

With icons

With shortcuts
My Account

Checkboxes
Status
Checkboxes with icons
Radio group
Panel Position
Destructive

Avatar menu

Complex
File

Recent Projects



View

USAGE

1<mo-dropdown>2  <button popovertarget="m1">Options</button>3  <menu popover id="m1">4    <div data-label>Group label</div>5    <button role="menuitem">Item <span data-shortcut>⌘N</span></button>6    <button role="menuitemcheckbox" aria-checked="true">Toggle</button>7    <hr />8    <button role="menuitem" popovertarget="s1">Submenu…</button>9    <menu popover id="s1">10      <button role="menuitem">Nested item</button>11    </menu>12  </menu>13</mo-dropdown>

API

NAMEKINDDESCRIPTION
<mo-dropdown>elementPositioning, keyboard nav, focus return for the whole tree
popovertargetattributeOpens menus via Popover API; inside a menu it opens a side submenu
[role=menuitem*]attributeitem · menuitemcheckbox · menuitemradio (aria-checked toggles)
[data-label]attributeNon-interactive group heading
[data-shortcut]attributeRight-aligned key hint
[data-variant=danger]attributeDestructive item styling
--mo-dropdown-min-width / -radiustokenSurface hooks

FILES

src/css/dropdown.csssrc/css/shared.csssrc/js/dropdown.js
Install:mo add dropdown

THEMING · PLAYGROUND

This is the exact component from the examples above, wearing a completely different theme. Edit the tokens and --mo-* hooks in the editor — autocomplete knows them all — and the preview obeys in real time. Your CSS always wins.

Tokens & hooks — edit live
Global tokens
--accent--accent-foreground--border--destructive--foreground--muted-foreground--popover--popover-foreground--radius--ring
Component hooks
--mo-dropdown-min-width--mo-dropdown-radius

Preview

Sealer head

Your CSS

Try it: type --mo- for the component hooks, or edit any value — the preview obeys in real time.