This documentation is under construction. Pages can be missing or change at any time. Follow it on GitHub.

Skip to content

Context Menu

A menu that appears at the pointer on right click or long press.

Examples#

Using with Menu#

A context menu should supplement a primary way to perform the same actions. This image card exposes actions through a visible menu button and reuses them in the context menu for right-click and long-press users.

Nested menu#

To create a submenu, create a MenuSubmenu inside the parent context menu. Use the MenuSubmenuTrigger part for the menu item that opens the nested menu.

API reference#

Import the components of the family:

use Phem\Ui\ContextMenu;
use function Phem\Ui\ContextMenuTrigger;

ContextMenu#

A menu that opens at the point of the pointer, on a right click or a long press: Base UI ContextMenu.Root, on the phem-context-menu controller.

Use the parts of Menu in it (MenuPopup, MenuItem, MenuSeparator…): they read the root, so they get the targets of phem-context-menu.

PropTypeDefault
sideOffsetint-5
alignOffsetint2
handle?stringnull
defaultOpenboolfalse
triggerId?stringnull
disabledboolfalse
autoHighlightbool|stringfalse
filterbooltrue
modalbooltrue
openOnHoverboolfalse
delayint100
loopFocusbooltrue
highlightItemOnHoverbooltrue
orientation'horizontal' | 'vertical'Orientation::Vertical
side'top' | 'bottom' | 'left' | 'right' | 'inline-start' | 'inline-end'Side::Bottom
align'start' | 'center' | 'end'Align::Start
collisionPaddingint5
children?Htmlnull
...attrsarray[]

ContextMenuTrigger#

The area of the page that opens the menu on a right click.

PropTypeDefault
children?Htmlnull
...restmixed—

The source of the examples: examples/ui/ContextMenu.phem.

Phem
Esc
↑↓ to navigate↵ to openEsc to close