https://github.com/tableflip/react-copy-text
Copy text to the clipboard like it's 1999
https://github.com/tableflip/react-copy-text
Last synced: about 1 year ago
JSON representation
Copy text to the clipboard like it's 1999
- Host: GitHub
- URL: https://github.com/tableflip/react-copy-text
- Owner: tableflip
- License: mit
- Created: 2017-12-01T11:41:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-23T08:48:15.000Z (over 8 years ago)
- Last Synced: 2025-03-18T13:05:56.473Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/react-copy-text
- Size: 73.2 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-copy-text
[](https://travis-ci.org/tableflip/react-copy-text) [](https://david-dm.org/tableflip/react-copy-text) [](https://standardjs.com)
> Copy text to the clipboard like it's 1999
Beautifully simples React component to copy the `text` you give to it, with optional `onCopied` callback so you know when it's done.
## Install
```sh
npm install react-copy-text
```
## Usage
```js
import React, { Component } from 'react'
import CopyText from 'react-copy-text'
export default class App extends Component {
state = {textToCopy: ''}
onButtonClick = () => this.setState({ textToCopy: 'NOW: ' + Date.now() })
onCopied = (text) => console.log(`${text} was copied to the clipboard`)
render () {
return (
Copy some text
)
}
}
```
## API
### ``
#### `text`
Type: `PropTypes.string`
The text to copy to the clipboard.
#### `onCopied`
Type: `PropTypes.func`
Callback function called after the text has been copied to the clipboard. Passed the text that was copied.
## Contribute
Feel free to dive in! [Open an issue](https://github.com/tableflip/react-copy-text/issues/new) or submit PRs.
## License
[MIT](LICENSE) © Alan Shaw
---
A [(╯°□°)╯︵TABLEFLIP](https://tableflip.io) side project.