Examples
File context menu
Right clicking a file row opens its actions at the pointer instead of a fixed anchor.
Preview
q3-forecast.xlsx
Sofia Davis edited June 14, 2027
Open
Download
Rename
Copy link
Move to archive
Delete
HTML
<bs:bsui-context-menu>
<bs:bsui-context-menu-trigger>
<bs:bsui-stack direction="row" gap="3" align="center" justify="space-between">
<bs:bsui-stack direction="column" gap="1">
<bs:bsui-text content="q3-forecast.xlsx" variant="label" tag="span" />
<bs:bsui-text content="Sofia Davis edited June 14, 2027" variant="caption" tag="span" />
</bs:bsui-stack>
<bs:bsui-badge label="2.4 MB" variant="secondary" />
</bs:bsui-stack>
</bs:bsui-context-menu-trigger>
<bs:bsui-context-menu-popup>
<bs:bsui-context-menu-item label="Open" />
<bs:bsui-context-menu-item label="Download" />
<bs:bsui-context-menu-item label="Rename" />
<bs:bsui-context-menu-item label="Copy link" />
<bs:bsui-context-menu-item label="Move to archive" />
<bs:bsui-context-menu-item label="Delete" />
</bs:bsui-context-menu-popup>
</bs:bsui-context-menu>How it works
The context menu store listens for the context menu gesture through a directive on the wrapped row, suppresses the native menu, and opens its popup at the pointer coordinates held in context. Arrow keys then walk the items and Escape returns focus to the row.
Every behaviour on this page is the WordPress Interactivity API: each component registers its own store, seeds its state in a server rendered context, and wires events with directives in the markup above. There is no page specific JavaScript.