Examples
Menu in a dialog
A kebab menu opens above dialog content and claims the first Escape press without taking the dialog down with it.
Preview
Export analytics
The export covers June 2027 across every project.
Last export ran June 21, 2027
Copy link to last export
Email me the file
Delete last export
HTML
<bs:bsui-dialog>
<bs:bsui-dialog-trigger trigger_label="Export analytics" trigger_variant="outline" />
<bs:bsui-dialog-backdrop />
<bs:bsui-dialog-popup>
<bs:bsui-dialog-header>
<bs:bsui-dialog-title content="Export analytics" />
<bs:bsui-dialog-description content="The export covers June 2027 across every project." />
</bs:bsui-dialog-header>
<bs:bsui-dialog-content>
<bs:bsui-stack direction="column" gap="4" align="stretch">
<bs:bsui-field>
<bs:bsui-field-label text="File name" />
<bs:bsui-input name="filename" defaultValue="analytics-june-2027" />
</bs:bsui-field>
<bs:bsui-stack direction="row" gap="2" align="center" justify="space-between">
<bs:bsui-text content="Last export ran June 21, 2027" variant="muted" tag="span" />
<bs:bsui-menu>
<bs:bsui-menu-trigger trigger_label="⋯" trigger_variant="ghost" trigger_size="icon-sm" />
<bs:bsui-menu-popup>
<bs:bsui-menu-item label="Copy link to last export" />
<bs:bsui-menu-item label="Email me the file" />
<bs:bsui-menu-item label="Delete last export" />
</bs:bsui-menu-popup>
</bs:bsui-menu>
</bs:bsui-stack>
</bs:bsui-stack>
</bs:bsui-dialog-content>
<bs:bsui-dialog-footer>
<bs:bsui-dialog-close variant="outline" label="Cancel" />
<bs:bsui-dialog-close variant="default" label="Export" />
</bs:bsui-dialog-footer>
</bs:bsui-dialog-popup>
</bs:bsui-dialog>How it works
Both overlays register in a shared layer stack, so the menu store anchors its popup to the kebab trigger inside the modal and closes alone on the first Escape. The dialog store keeps its focus trap around the whole surface and only reclaims key handling once the menu has left the stack.
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.