Svelte Action

Clipboard

Allows you to quickly copy data to the clipboard.

typescript
import { clipboard } from '@skeletonlabs/skeleton';
Source Page Source

Demo

If your data is available as a primitive data type (string, integer, etc), you can provide it directly to the action.

Copying HTML Contents

To copy the innerHTML for an element, set a data-clipboard on your target, then provide an element reference to the action.

This div is set to 'contenteditable'. Make changes then tap copy.

Copying Input Values

To copy a form input value, set a data-clipboard data attribute on your target, then provide an input reference to the action.