Skip to content

Examples

Cookie settings card

Three labelled switch rows split by hairline separators, closed by a Cancel and Save footer.

Preview

Cookie settings

Manage your cookie settings here.

Strictly necessary Essential for the site to work. Always on.
Functional cookies Remember what you customise between visits.
Performance cookies Help us learn which pages are slow.
HTML
<bs:bsui-card>
  <bs:bsui-card-header>
    <bs:bsui-card-title label="Cookie settings" />
    <bs:bsui-card-description label="Manage your cookie settings here." />
  </bs:bsui-card-header>
  <bs:bsui-card-content>
    <bs:bsui-stack direction="column" gap="3" align="stretch">
      <bs:bsui-stack direction="row" gap="4" align="center" justify="space-between">
        <bs:bsui-stack direction="column" gap="1">
          <bs:bsui-text content="Strictly necessary" variant="label" tag="span" />
          <bs:bsui-text content="Essential for the site to work. Always on." variant="caption" tag="span" />
        </bs:bsui-stack>
        <bs:bsui-switch defaultChecked="true" disabled="true" />
      </bs:bsui-stack>
      <bs:bsui-separator />
      <bs:bsui-stack direction="row" gap="4" align="center" justify="space-between">
        <bs:bsui-stack direction="column" gap="1">
          <bs:bsui-text content="Functional cookies" variant="label" tag="span" />
          <bs:bsui-text content="Remember what you customise between visits." variant="caption" tag="span" />
        </bs:bsui-stack>
        <bs:bsui-switch defaultChecked="true" />
      </bs:bsui-stack>
      <bs:bsui-separator />
      <bs:bsui-stack direction="row" gap="4" align="center" justify="space-between">
        <bs:bsui-stack direction="column" gap="1">
          <bs:bsui-text content="Performance cookies" variant="label" tag="span" />
          <bs:bsui-text content="Help us learn which pages are slow." variant="caption" tag="span" />
        </bs:bsui-stack>
        <bs:bsui-switch />
      </bs:bsui-stack>
    </bs:bsui-stack>
  </bs:bsui-card-content>
  <bs:bsui-card-footer justify="end">
    <bs:bsui-button label="Cancel" variant="outline" />
    <bs:bsui-button label="Save preferences" variant="default" />
  </bs:bsui-card-footer>
</bs:bsui-card>

How it works

Each switch binds its checked state to one key of a preferences object in the store, with the disabled strictly necessary row excluded from writes. Save serialises the object while Cancel restores the snapshot context took when the card mounted.

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.