Skip to main content
VelinStyle v0.9.0
⌂ Home
  1. Docs
  2. Components
  3. Copy

Copy

The <velin-copy> Web Component copies text to the clipboard and shows a short success state. Use it beside code blocks, API keys, or share links.

Basic

npm install @birdapi/velinstyle
<velin-copy value="npm install @birdapi/velinstyle" label="Copy"></velin-copy>

Alternatively set text (alias), data-source on the element, or copy from a nearby element id via data-source="#copyDemoText".

Attributes

AttributeNotes
value / textString copied on click (first match wins)
labelOptional visible label beside the icon
data-sourceCSS selector; copies textContent of the matched node

Events

Listen for velin-copied (bubbles) — detail.value contains the copied string.

document.querySelector('velin-copy').addEventListener('velin-copied', (e) => {
  console.log('Copied', e.detail.value);
});

Declarative twin: velin-copy HTML attribute — see HTML attributes.

Accessibility