Skip to content
A simple copy button for React applications.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.babelrc
.gitignore
LICENSE
README.md
package-lock.json
package.json
rollup.config.js

README.md

ui-copy-button

version

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

Installation

npm i ui-copy-button

Usage

import React from 'react';
import CopyButton from 'ui-copy-button';

Required Props:

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

Optional Props:

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

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} />
You can’t perform that action at this time.