0.1.0 • Published 5 years ago

ui-copy-button v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

ui-copy-button

A (really) simple component to copy text from a selector or from props.

Required Props:

PropsDescription
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

Optional Props:

PropsDescription
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

Usage Examples

Selecting text from an element:

<CopyButton elementId="root" />

Selecting text from props:

<CopyButton textToCopy="Copied from props!" />

Set a custom class name:

<CopyButton className="btn copy" textToCopy="Copied from props!" />

Override button text:

<CopyButton elementId="root">I'm a copy button</CopyButton>

Call a function when a copy is successful:

<CopyButton textToCopy="Text copied from props!" onCopied={someCustomAction} />