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
| Prop | Type | Default | Description |
|---|---|---|---|
text | string | - | Text to copy (required). |
label | string | Copy to clipboard | Button label. |
copiedLabel | string | Copied | Confirmation text (2s). |
Events
document.addEventListener("ink:copy", (event) => {
console.log("copied: " + event.detail.text + " (ok: " + event.detail.ok + ")");
});Accessibility
- State lives in the accessible name, so AT announces the confirmation.
- 44px minimum, visible focus, real button.