Skip to content

Clipboard

<loomi-clipboard> wraps text or content and appends a copy icon button. When clicked, it copies the wrapped text and briefly shows subtle copied feedback.

Terminal window
npm install @loomidev/clipboard lit
import "@loomidev/clipboard";
INV-2048
<loomi-clipboard>INV-2048</loomi-clipboard>

If the component wraps a div, it copies the text content of that div.

https://example.com/invite/team-alpha
<loomi-clipboard>
<div>https://example.com/invite/team-alpha</div>
</loomi-clipboard>

Use value when the visible content differs from the clipboard value.

SSH key fingerprint copied from account settings
<loomi-clipboard value="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA...">
<span>SSH key fingerprint copied from account settings</span>
</loomi-clipboard>

For the library-wide baseline, see Foundations — Accessibility.

For the shared container and viewport rules, see Foundations — Responsive behavior.

For theme activation, token overrides, and contrast guidance, see Foundations — Dark mode.

AttributeDefaultDescription
value(blank)Explicit clipboard value. Falls back to slotted text content.
copy-labelCopy to clipboardAccessible label before copy.
copied-labelCopiedFeedback text and accessible label after copy.
disabledfalseDisables the copy button. (boolean)
SlotDescription
(default)Content placed inside the component.
EventDetailDescription
loomi-copied{ value }The value was copied successfully.
loomi-copy-error{ value, error }Copying failed.
document.querySelector("loomi-clipboard").addEventListener("loomi-copied", (event) => {
console.log(event.detail.value);
});
  • @loomidev/core
  • @loomidev/icons