Skip to content

CopyButton

Copies text with confirmation. Clipboard API first, legacy fallback second, label swap always.

Example

<CopyButton text="npm install astro-ink" label="Copy install command" />

Props

PropTypeDefaultDescription
textstring-Text to copy (required).
labelstringCopy to clipboardButton label.
copiedLabelstringCopiedConfirmation text (2s).

Events

document.addEventListener("ink:copy", (event) => {
  console.log("copied: " + event.detail.text + " (ok: " + event.detail.ok + ")");
});

Accessibility