Copy Button

Click-to-copy button with clipboard icon and visual feedback. Supports inline, input field, sizes, and inset variants.

This component requires softui.js for interactive behavior.

Default

npm install softui-css
https://softui-css.netlify.app
sk-1234-abcd-5678-efgh-9012
<div class="sui-copy">
  <span class="sui-copy-text">npm install softui-css</span>
  <button type="button" class="sui-copy-btn" data-sui-copy aria-label="Copy">
    <svg viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
  </button>
</div>

<!-- Text is read from the .sui-copy-text sibling -->

Inline

sk-1234-abcd-5678
Invite code: SOFTUI2026
<!-- data-sui-copy="text" copies that exact string -->
<div style="display:flex;align-items:center;gap:6px;">
  <code style="font-size:13px;">sk-1234-abcd-5678</code>
  <button type="button" class="sui-copy-inline" aria-label="Copy" data-sui-copy="sk-1234-abcd-5678">
    <svg viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
  </button>
</div>
<div style="display:flex;align-items:center;gap:6px;">
  <span style="font-size:13px;">Invite code: <strong>SOFTUI2026</strong></span>
  <button type="button" class="sui-copy-inline" aria-label="Copy" data-sui-copy="SOFTUI2026">
    <svg viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
  </button>
</div>

With Input

<div class="sui-copy-input">
  <input type="text" class="sui-input" value="https://softui-css.netlify.app" readonly>
  <button type="button" class="sui-copy-btn" data-sui-copy aria-label="Copy">
    <svg viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
  </button>
</div>

<!-- Auto-reads value from the .sui-input sibling -->

Sizes

Small
npm install softui-css
Default
npm install softui-css
Large
npm install softui-css
<!-- Small -->
<div class="sui-copy sui-copy-sm">
  <span class="sui-copy-text">npm install softui-css</span>
  <button type="button" class="sui-copy-btn" data-sui-copy aria-label="Copy">
    <svg viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
  </button>
</div>

<!-- Default -->
<div class="sui-copy">
  <span class="sui-copy-text">npm install softui-css</span>
  <button type="button" class="sui-copy-btn" data-sui-copy aria-label="Copy">
    <svg viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
  </button>
</div>

<!-- Large -->
<div class="sui-copy sui-copy-lg">
  <span class="sui-copy-text">npm install softui-css</span>
  <button type="button" class="sui-copy-btn" data-sui-copy aria-label="Copy">
    <svg viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
  </button>
</div>

Inset

npm install softui-css
sk-1234-abcd-5678-efgh-9012
<div class="sui-copy sui-copy-inset">
  <span class="sui-copy-text">npm install softui-css</span>
  <button type="button" class="sui-copy-btn" data-sui-copy aria-label="Copy">
    <svg viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
  </button>
</div>

Reference

Attribute / Event / ClassDescription
data-sui-copyMakes the button copy on click. A value copies that string; empty reads the .sui-copy-text or .sui-input in the same .sui-copy / .sui-copy-input.
sui-copy eventFires on success with detail.text. The check shows for 1.5s, then the button's own content returns. Falls back to execCommand('copy') where the Clipboard API is missing or denied (e.g. plain http).
sui-copy-error eventFires on failure with detail.text and detail.error.
.copiedAdded on success while the check shows.
.copy-failedAdded on failure: danger colour and a cross for 1.5s.

Delete this item?

This action cannot be undone. This will permanently delete the item and remove all associated data.