Skip to content

Examples

Share document card

A copyable share link above a people list where a compact select sets the permission for each person.

Preview

Share this document

Anyone with the link can view this document.

People with access
Olivia Martin b@example.com
Isabella Nguyen i@example.com
Ethan Thompson e@example.com
HTML
<bs:bsui-card>
  <bs:bsui-card-header>
    <bs:bsui-card-title label="Share this document" />
    <bs:bsui-card-description label="Anyone with the link can view this document." />
  </bs:bsui-card-header>
  <bs:bsui-card-content>
    <bs:bsui-stack direction="column" gap="4" align="stretch">
      <bs:bsui-stack direction="row" gap="2" align="center">
        <bs:bsui-input name="share_link" defaultValue="https://acme.app/d/q3-forecast" />
        <bs:bsui-button label="Copy link" variant="outline" />
      </bs:bsui-stack>
      <bs:bsui-separator />
      <bs:bsui-text content="People with access" variant="label" tag="span" />
      <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="OM" alt="Olivia Martin" />
          <bs:bsui-stack direction="column" gap="1">
            <bs:bsui-text content="Olivia Martin" variant="label" tag="span" />
            <bs:bsui-text content="b@example.com" variant="muted" tag="span" />
          </bs:bsui-stack>
        </bs:bsui-stack>
        <bs:bsui-select defaultValue="edit" placeholder="Permission">
          <bs:bsui-select-trigger />
          <bs:bsui-select-popup>
            <bs:bsui-select-option value="edit" label="Can edit" />
            <bs:bsui-select-option value="view" label="Can view" />
          </bs:bsui-select-popup>
        </bs:bsui-select>
      </bs:bsui-stack>
      <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="IN" alt="Isabella Nguyen" />
          <bs:bsui-stack direction="column" gap="1">
            <bs:bsui-text content="Isabella Nguyen" variant="label" tag="span" />
            <bs:bsui-text content="i@example.com" variant="muted" tag="span" />
          </bs:bsui-stack>
        </bs:bsui-stack>
        <bs:bsui-select defaultValue="view" placeholder="Permission">
          <bs:bsui-select-trigger />
          <bs:bsui-select-popup>
            <bs:bsui-select-option value="edit" label="Can edit" />
            <bs:bsui-select-option value="view" label="Can view" />
          </bs:bsui-select-popup>
        </bs:bsui-select>
      </bs:bsui-stack>
      <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="ET" alt="Ethan Thompson" />
          <bs:bsui-stack direction="column" gap="1">
            <bs:bsui-text content="Ethan Thompson" variant="label" tag="span" />
            <bs:bsui-text content="e@example.com" variant="muted" tag="span" />
          </bs:bsui-stack>
        </bs:bsui-stack>
        <bs:bsui-select defaultValue="view" placeholder="Permission">
          <bs:bsui-select-trigger />
          <bs:bsui-select-popup>
            <bs:bsui-select-option value="edit" label="Can edit" />
            <bs:bsui-select-option value="view" label="Can view" />
          </bs:bsui-select-popup>
        </bs:bsui-select>
      </bs:bsui-stack>
    </bs:bsui-stack>
  </bs:bsui-card-content>
</bs:bsui-card>

How it works

The copy action reads the link input from state, writes it to the clipboard and swaps the button label to Copied for two seconds through context. Each permission select commits straight into the access list held in the store.

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.