New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bicycle-codes/copy-button

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bicycle-codes/copy-button

Copy button made with web components

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-80%
Maintainers
1
Weekly downloads
 
Created
Source

copy button

tests module semantic versioning dependencies license

A button to copy some text to the system clipboard, made with webcomponents, with no dependencies.

install

npm i -S @bicycle-codes/copy-button

demonstration

See bicycle-codes.github.io/copy-button for an example.

globals

This looks at css variables --success-color and --copy-color which determines the color of the success checkmark and copy icon.

use

Include this package, then use the tag <copy-button> in HTML.

Example without a build step

Copy the files

Copy files so they are accessible by your web server.

JS
cp ./node_modules/@bicycle-codes/copy-button/dist/index.min.js public/copy-button.js
CSS
cp ./node_modules/@bicycle-codes/copy-button/dist/style.min.css public/copy-button.css
Use in HTML
<head>
    <!-- style -->
    <link rel="stylesheet" href="./copy-button.css">
</head>

<body>
    <!-- use the tag -->
    <copy-button payload="example text"></copy-button>

    <!-- include the script -->
    <script src="/copy-button.js" type="module"></script>
</body>

With a JS build step

We expose several import options

// default, unminified
import '@bicycle-codes/copy-button'

// minified
import '@bicycle-codes/copy-button/min'

// style
import '@bicycle-codes/copy-button/style.css'

// style, minifed
import '@bicycle-codes/copy-button/min/style.css'

In vite, for example, import like this

import '@bicycle-codes/copy-button'
import '@bicycle-codes/copy-button/style.css'
// or minified css
import '@bicycle-codes//copy-button/min/style.css'

CSS

Override the variables --success-color and --copy-color to customize the color.

.copy-button {
    --success-color: green;
    --copy-color: blue;
}

Create a button like this

screenshot of the button, pre-click


screenshot of the button, post-click

Keywords

FAQs

Package last updated on 03 Jun 2024

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