npm
san-copy-to-clipboardCopy to clipboard React component
Based on copy-to-clipboard
Installation
NPM
npm install --save san san-copy-to-clipboard
Don't forget to manually install peer dependencies (san
) if you use npm@3.
1998 Script Tag:
(Module exposed as `CopyToClipboard`)
Demo reference
Usage
;; const AppComponent = san; const app = ;app;
Options
text
: PropTypes.string.isRequired
Text to be copied to clipboard
onCopy
: PropTypes.func
Optional callback, will be called when text is copied
onCopy(text, result)
result (bool)
: Returns true
if copied successfully, else false
.
options
: PropTypes.shape({debug: bool, message: string})
Optional copy-to-clipboard options.
See API docs for details
slot
CopyToClipboard is a simple wrapping component, you can render any component with slot, which will be used to capture clicks.
<copy-to-clipboard text="Hello!"> <button>Copy to clipboard</button></copy-to-clipboard>
Development and testing
Currently is being developed and tested with the latest stable Node 8
on OSX
.
To run example covering all CopyToClipboard
features, use yarn start
, which will compile example/Example.js
git clone git@github.com:zttonly/san-copy-to-clipboard.gitcd san-copy-to-clipboardyarn installyarn start # then open http://localhost:8822
Tests
# to run ESLint check yarn lint
License
MIT