@wordpress/components
Version:
UI components for WordPress.
26 lines (20 loc) • 672 B
Markdown
# ClipboardButton
With a clipboard button, users copy text (or other elements) with a single click or tap.

## Usage
```jsx
import { ClipboardButton } from '@wordpress/components';
import { withState } from '@wordpress/compose';
const MyClipboardButton = withState( {
hasCopied: false,
} )( ( { hasCopied, setState } ) => (
<ClipboardButton
isPrimary
text="Text to be copied."
onCopy={ () => setState( { hasCopied: true } ) }
onFinishCopy={ () => setState( { hasCopied: false } ) }
>
{ hasCopied ? 'Copied!' : 'Copy Text' }
</ClipboardButton>
) );
```