Context menu

stable 2.3 kB
<hkContextMenu>

A right-click menu that clamps itself inside its container, so it never opens half off-screen near an edge.

#menu#right-click

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
hkContextMenuHkMenuItem[][]Items to show.
disabledbooleanfalseFalls back to the browser menu.

Outputs

  • menuSelectEventEmitter<HkMenuItem>

    Emits the chosen item.

Keyboard

  • Shift + F10 / Menu key Opens the menu from the keyboard
  • ↑ / ↓ Moves through items
  • Escape Closes and restores focus

Theming

Component tokens, each falling back to a global one:

PropertyDefaultControls
--hk-context-bg#ffffffPanel background.
--hk-context-danger#dc2626Colour for destructive items.

Accessibility

  • Opens from the keyboard menu key as well as right-click — otherwise the actions are mouse-only.
  • Coordinates are clamped to the container, so the panel is always fully visible.
  • Focus returns to the target element on close.

More in Overlay