ClipX.js – Lightweight Copy to Clipboard Library

ClipX.js – Lightweight Copy to Clipboard Library

ClipX.js is a super-small JavaScript library that makes copying, cutting, and pasting text easy. It’s perfect for blogs, documentation, and apps that need a copy to clipboard button without heavy dependencies. At around 1KB–2KB in size, ClipX.js is fast, flexible, and works in modern browsers.

What is ClipX.js?

ClipX.js is designed to handle common clipboard actions like copy, cut, and paste. It also includes built-in toast notifications so users know the action worked. You can customize messages, styles, and even disable features you don’t need.

Key Features

  • Small & Fast – Around 1–2KB, loads instantly.
  • Built-in Notifications – Shows “Copied!” messages without extra code.
  • Easy Setup – Just add the script and attach it to your buttons.
  • Customizable – Change styles, messages, and behavior with attributes.
  • No Dependencies – Works with plain HTML and JavaScript.

How to Install ClipX.js

  1. Via NPM:
    npm install clipxjs
  2. Via CDN:
    <script src="https://cdn.jsdelivr.net/npm/clipxjs/dist/clipx.min.js"></script>

Basic Usage Example

Once installed, you can use ClipX.js with just a few lines:


<button data-clipx-text="Hello World">Copy Text</button>

<script src="https://cdn.jsdelivr.net/npm/clipxjs/dist/clipx.min.js"></script>
<script>
  var clipx = new clipx();
  clipx.attach("[data-clipx-text], [data-clipx-target]");
</script>
  

Copy from Another Element


<p id="copy-me">This text will be copied.</p>
<button data-clipx-target="#copy-me">Copy Paragraph</button>
  

Custom Messages and Toast Position


<button 
  data-clipx-text="Custom text" 
  data-clipx-msg="Copied successfully!" 
  data-clipx-toast-position="bottom"
  data-clipx-duration="4000">
  Copy with Custom Toast
</button>
  

Why Use ClipX.js?

Many websites add “Copy” buttons for code snippets, referral links, or form fields. ClipX.js makes this easy without heavy libraries. It’s perfect for:

  • Technical blogs with code examples
  • Web apps that let users copy IDs or tokens
  • Forms where you need a quick copy action

Final Thoughts

ClipX.js is an excellent choice if you need a simple, lightweight, and customizable clipboard library. It improves user experience, works fast, and is easy to integrate with any HTML page.