Svelte Copy Demo


Simple Example

<button use:copy={text}> Copy </button>

Copy events

<button
    use:copy={text}
    on:svelte-copy={(e) => alert(e.detail)}
    on:svelte-copy:error={(e) => alert(e.detail.message)}
>
    Alert on copy & error
</button>

Custom Triggers

<button use:copy={{ text, events: ['pointerover'] }}>
    Copy on hover
</button>

By default svelte-copy only listens to the click event.