Examples
Workspace switcher
A workspace header joining a switcher menu with a creation dialog, menu for the fast path and form for the new one.
Preview
Acme Inc
Pro plan, 8 members
Acme Inc
Northwind Labs
Personal
Create a workspace
Workspaces keep projects, members and billing separate.
Free
Pro
Enterprise
HTML
<bs:bsui-stack direction="row" gap="3" align="center" justify="space-between">
<bs:bsui-stack direction="row" gap="3" align="center">
<bs:bsui-avatar fallback="AC" alt="Acme Inc" />
<bs:bsui-stack direction="column" gap="1">
<bs:bsui-text content="Acme Inc" variant="label" tag="span" />
<bs:bsui-text content="Pro plan, 8 members" variant="caption" tag="span" />
</bs:bsui-stack>
</bs:bsui-stack>
<bs:bsui-stack direction="row" gap="2" align="center">
<bs:bsui-menu>
<bs:bsui-menu-trigger trigger_label="Switch" trigger_variant="outline" />
<bs:bsui-menu-popup>
<bs:bsui-menu-item label="Acme Inc" />
<bs:bsui-menu-item label="Northwind Labs" />
<bs:bsui-menu-item label="Personal" />
</bs:bsui-menu-popup>
</bs:bsui-menu>
<bs:bsui-dialog>
<bs:bsui-dialog-trigger trigger_label="New workspace" />
<bs:bsui-dialog-backdrop />
<bs:bsui-dialog-popup>
<bs:bsui-dialog-header>
<bs:bsui-dialog-title content="Create a workspace" />
<bs:bsui-dialog-description content="Workspaces keep projects, members and billing separate." />
</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="Name" />
<bs:bsui-input name="workspace_name" placeholder="Acme Inc" />
</bs:bsui-field>
<bs:bsui-field>
<bs:bsui-field-label text="Plan" />
<bs:bsui-select name="plan" defaultValue="free" placeholder="Pick a plan">
<bs:bsui-select-trigger />
<bs:bsui-select-popup>
<bs:bsui-select-option value="free" label="Free" />
<bs:bsui-select-option value="pro" label="Pro" />
<bs:bsui-select-option value="enterprise" label="Enterprise" />
</bs:bsui-select-popup>
</bs:bsui-select>
<bs:bsui-field-description text="Free includes three projects and two members." />
</bs:bsui-field>
</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="Create workspace" />
</bs:bsui-dialog-footer>
</bs:bsui-dialog-popup>
</bs:bsui-dialog>
</bs:bsui-stack>
</bs:bsui-stack>How it works
The menu store lists workspaces from context and switching writes the active id, which the header identity re-renders from. The dialog form validates the name, and creating appends a workspace to the same store before switching to it.
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.