Skip to content

CompactJS/clipboard

Repository files navigation

@compactjs/clipboard

Copy to clipboard.

Version License: MIT

· Homepage · View Demo · Report Bug / Request Feature ·

Table of Contents

Install

NPM:

npm install @compactjs/clipboard

CDN:

<script src="https://unpkg.com/@compactjs/clipboard/dist/index.umd.js"></script>

Usage

As module:

import { clipboard } from '@compactjs/clipboard';

API:

/**
 * Copy text to clipboard.
 * @param input Either text to copy or HTMLElement to copy from
 */
function clipboard(
  input: string | HTMLTextAreaElement | HTMLInputElement
): void;

Note: A copy to clipboard need to be triggered by user action, like a button press!

Example:

document
  .getElementById('copy-string')
  .addEventListener('click', () =>
    clipboard('This text is going to be copied.')
  );

Have a look at the example.

Or checkout the demo.

Run tests

npm run test

Contact

👤 Timo Bechtel

🤝 Contributing

Contributions, issues and feature requests are welcome!

  1. Check issues
  2. Fork the Project
  3. Create your Feature Branch (git checkout -b feat/AmazingFeature)
  4. Test your changes npm run test
  5. Commit your Changes (git commit -m 'feat: add amazingFeature')
  6. Push to the Branch (git push origin feat/AmazingFeature)
  7. Open a Pull Request

Commit messages

This project uses semantic-release for automated release versions. So commits in this project follow the Conventional Commits guidelines. I recommend using commitizen for automated commit messages.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Distributed under the MIT License.


This README was generated with ❤️ by readme-md-generator