Context Menu
A menu that appears at the pointer on right click or long press.
Examples#
#
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.
#
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.
| Prop | Type | Default |
|---|---|---|
sideOffset | int | -5 |
alignOffset | int | 2 |
handle | ?string | null |
defaultOpen | bool | false |
triggerId | ?string | null |
disabled | bool | false |
autoHighlight | bool|string | false |
filter | bool | true |
modal | bool | true |
openOnHover | bool | false |
delay | int | 100 |
loopFocus | bool | true |
highlightItemOnHover | bool | true |
orientation | 'horizontal' | 'vertical' | Orientation::Vertical |
side | 'top' | 'bottom' | 'left' | 'right' | 'inline-start' | 'inline-end' | Side::Bottom |
align | 'start' | 'center' | 'end' | Align::Start |
collisionPadding | int | 5 |
children | ?Html | null |
...attrs | array | [] |
ContextMenuTrigger#
The area of the page that opens the menu on a right click.
| Prop | Type | Default |
|---|---|---|
children | ?Html | null |
...rest | mixed | — |
The source of the examples: examples/ui/ContextMenu.phem.