❏ Just wrap it with this
npm i svelte-code-copy
pre is optional.
<CodeCopy> copies the innerText of <code>
<script>
import { CodeCopy } from 'svelte-code-copy'
</script>
<CodeCopy>
<pre>
<code>
<!-- Your code block -->
</code>
</pre>
</CodeCopy>
| Prop | Type | Default |
|---|---|---|
| onCopy | function |
undefined |
| size | number |
18 |
| background | string |
transparent |
| color | string |
whitesmoke |
| success | string |
green |
| error | string |
red |
| top | string |
0.5rem |
| right | string |
0.5rem |
| border | string |
none |
| padding | string |
0.25rem |
| borderRadius | string |
0.25rem |
| margin | string |
0 |
| effect | string |
pop |
| duration | number |
150 |