Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svelte-copy

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-copy

Ever wanted to copy something to clipboard? Say hello to Svelte Copy ✨

  • 1.2.4
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Svelte Copy

Ever wanted to copy something to clipboard? Say hello to Svelte Copy ✨

Demo

Installing

npm install svelte-copy -D

Using

Let's make a button that when you click it copies Hello World to the clipboard:

<script>
    import { copy } from 'svelte-copy';
</script>

<button use:copy={"Hello World"}>
    Click me!
</button>

Events

There are some custom events you can use on elements that have the copy action:

  • on:svelte-copy This will fire when text is copied, you have access to the copied text if needed with event.detail:

    <button
        use:copy={'Hello from alert'}
        on:svelte-copy={(event) => alert(event.detail)}>
        Click to cause alert on copy
    </button>
    
  • on:svelte-copy:error This event will fire if there is an error in copying to clipboard, you have access to the error with event.detail:

    <button
        use:copy={'Some text'}
        on:svelte-copy:error="{(event) =>
            alert(`There was an error: ${event.detail.message}`)}">
        Click to cause alert on copy
    </button>
    

Support

FAQs

Package last updated on 04 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc