Hololink UI is under active development. Components, APIs and these docs may change without notice.
Holo Menu & Menu Item
<holo-menu> is a popup menu built on the native Popover API (like <holo-popover>). Put a
trigger element in the trigger slot and <holo-menu-item> children in the default slot. Arrow
keys / Home / End move focus between items, Enter/Space activates the focused item, and Esc closes
the menu and returns focus to the trigger.
holoClose bubbles and is composed, so a <holo-menu> nested inside a dialog, drawer, popover or menu also fires holoClose on that ancestor. A handler like () => menu.removeAttribute('open') on a dialog would close the dialog as soon as the nested menu closes. Guard the handler so it only reacts to its own element’s event:
menu.addEventListener('holoClose', event=> {
// event.target is the element that closed; event.currentTarget is the one we listen on.
if (event.target===event.currentTarget) menu.removeAttribute('open');
});
Use the guard on every holoClose listener you attach to a host that may contain a menu.
The menu uses the Popover API (popover="auto") on an element with role="menu". Each <holo-menu-item> sets role="menuitem" on itself and takes tabindex="-1". The trigger goes in the trigger slot. The component sets aria-haspopup="menu" on it (unless you already set one) and keeps aria-expanded in sync.
Key
Action
Enter, Space
On a button trigger, opens the menu (native click). On an item, selects it
ArrowDown
On the trigger: opens the menu and focuses the first item. In the menu: next item (wraps)
ArrowUp
On the trigger: opens the menu and focuses the last item. In the menu: previous item (wraps)
Home
Focuses the first item
End
Focuses the last item
Esc
Closes the menu and returns focus to the trigger
When the menu opens, focus moves to the first enabled item. When it closes, focus returns to the trigger.
Items use roving tabindex: only the focused item has tabindex="0".
Disabled items set aria-disabled="true" and are skipped by arrow-key navigation.
Selecting an item emits holoMenuSelect, then closes the menu. Clicking outside also closes it (native light dismiss).
There is no type-ahead (jumping by typed letter) and no support for submenus or checkable items.
The open and close transition only runs when prefers-reduced-motion: no-preference.
You provide:
A trigger that is a focusable, named control, normally a Button or Icon Button with a clear label.
Whether the menu popup is shown. Setting this to true calls the
native showPopover(); setting it to false calls hidePopover().
placement
placement
"bottom" | "end" | "start" | "top"
'bottom'
Which side of the trigger the menu is positioned on.
Events
Event
Detail
Description
holoClose
void
Emitted after the menu has closed (via Esc, outside click, item selection, or open being set
to false). Focus then returns to the trigger.
This event bubbles and is composed, so a menu nested in a dialog, drawer, popover or menu also
reaches holoClose listeners on that ancestor. In a handler on the host, guard with
event.target === event.currentTarget so that only this menu's own close is handled.
holoMenuSelect
string
Emitted when a holo-menu-item is activated. detail is the item's value. The menu closes
afterwards.
holoOpen
void
Emitted after the menu has opened.
Slots
Slot
Description
(default)
The holo-menu-item elements shown in the popup.
trigger
The element that opens and closes the menu, typically a holo-button. It
receives aria-haspopup and aria-expanded automatically.