react-copy

1.2.1 • Public • Published

Simplistic copy-to-clipboard component Build Status Dependencies

Works by selecting a string given as a prop and then copies it. Almost no dependencies.

Usage

npm install react-copy --save

or

yarn add react-copy
import Copy from 'react-copy';

...

<Copy textToBeCopied={this.state.text}>
    <button>
      Copy the text please please
    </button>
</Copy>

Properties

textToBeCopied

Type: PropTypes.string.isRequired

The text that should be copied on button click

children

Type: PropTypes.element.isRequired

Exactly one child is required as a click handler for copying, e.g. a button

onCopy

Type: PropTypes.func

A callback function called when copy function is called

style

Type: PropTypes.object

Optional style object

Example

For a real world use-case checkout a demo (https://github.com/hamsterbacke23/movierater)

Alternatives to this component

Also check out

Readme

Keywords

none

Package Sidebar

Install

npm i react-copy

Weekly Downloads

61

Version

1.2.1

License

MIT

Unpacked Size

258 kB

Total Files

12

Last publish

Collaborators

  • hamsterbacke23