Skip to content

Examples

Select in a drawer

A select opens inside a sliding side panel and its listbox tracks the trigger after the drawer has settled into place.

Preview

HTML
<bs:bsui-drawer position="right">
  <bs:bsui-drawer-trigger trigger_label="Delivery preferences" trigger_variant="outline" />
  <bs:bsui-drawer-backdrop />
  <bs:bsui-drawer-popup>
    <bs:bsui-text content="Delivery preferences" variant="title" tag="h3" />
    <bs:bsui-text content="Applies to every thread you follow." variant="muted" />
    <bs:bsui-field>
      <bs:bsui-field-label text="Digest frequency" />
      <bs:bsui-select name="frequency" defaultValue="daily" placeholder="Pick a cadence">
        <bs:bsui-select-trigger />
        <bs:bsui-select-popup>
          <bs:bsui-select-option value="instant" label="Instant" />
          <bs:bsui-select-option value="daily" label="Daily at 9:00" />
          <bs:bsui-select-option value="weekly" label="Weekly on Mondays" />
        </bs:bsui-select-popup>
      </bs:bsui-select>
      <bs:bsui-field-description text="Instant delivery can be noisy on busy repositories." />
    </bs:bsui-field>
    <bs:bsui-drawer-footer>
      <bs:bsui-drawer-close variant="default" label="Save preferences" />
      <bs:bsui-drawer-close variant="outline" label="Cancel" />
    </bs:bsui-drawer-footer>
  </bs:bsui-drawer-popup>
</bs:bsui-drawer>

How it works

The drawer store animates the panel with a transform, so the select store re-anchors its listbox once the slide settles rather than trusting coordinates measured mid-animation. Both overlays share the dismiss layer, letting Escape close the listbox first and the drawer second.

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.