svelte-copy-url-button Svelte Themes

Svelte Copy Url Button

Svelte based button component that copies the current url.

svelte-copy-url-button

Simple Svelte based button that copies the current url.

Installation

Using npm

Sapper or Other Svelte Bundler

For Sapper you need to install the package as a dev module to so it gets compiled. If you install it as a runtime dependency you will 500 errors on the server side. This is explained here.

$ npm i -D svelte-copy-url-button

PureJS

$ npm i --save svelte-copy-url-button

Usage

Basic usage from svelte looks like this:

<script>
import SvelteCopyUrlButton from 'svelte-copy-url-button';
// If url is not passed it will copy the url of the current page
let url = "https://svelte-copy-url-button.netlify.app/"
</script>

<SvelteCopyUrlButton
  class="customClassName"
  size="14"
  defaultText="Copy url"
  copiedText="Copied!"
  icon="{false}"
  timeout="1000"
  url="{url}"
/>

Demo

Demo with some of the options can be viewed here

Top categories

Loading Svelte Themes