Skip to content
A Fully Customizable Click-To-Copy Component for React
JavaScript CSS HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
src
.babelrc
.editorconfig
.eslintrc
.gitignore
.travis.yml
README.md
demo.gif
package-lock.json
package.json
rollup.config.js

README.md

react-copy-content

A Fully Customizable Click-To-Copy Component for React

NPM JavaScript Style Guide

Demo

Demo

Checkout the Live Demo

Install

npm install --save react-copy-content

Usage

import ClickToCopy from 'react-copy-content'

<ClickToCopy contentToCopy="This will be copied to your clipboard." />

Props

contentToCopy: String

This is the text that will be copied. It is a required prop.

onCopy: function

<ClickToCopy
  contentToCopy="This will be copied to the clipboard"
  onCopy={() => console.log("copy")}
/>

This is the callback function triggered after the content is copied to the clipboard

render: function

<ClickToCopy
  contentToCopy="This will be copied to the clipboard"
  render={props => (
    <a href="#copy" onClick={props.copy}>
      Copy
    </a>
  )}
/>

To render a custom component in place of the button, use the render prop. Inside your custom component, use props.copy to trigger the copy action.

License

MIT © akshayymahajan

You can’t perform that action at this time.