A (really) simple component to copy text from a selector or from props.
npm i ui-copy-button
import React from 'react';
import CopyButton from 'ui-copy-button';
Props | Description |
---|---|
textToCopy | (String) text to copy to clipboard - required if elementId prop is not set |
elementId | (String) DOM ID of element on the page - required if textToCopy prop is not set |
Props | Description |
---|---|
className | (String) custom class for button |
actionText | (String) text to display in the button when copy is successful' |
onCopied | (Function) run when copy is successful |
<CopyButton elementId="root" />
<CopyButton textToCopy="Copied from props!" />
<CopyButton className="btn copy" textToCopy="Copied from props!" />
<CopyButton elementId="root">I'm a copy button</CopyButton>
<CopyButton textToCopy="Text copied from props!" onCopied={someCustomAction} />