Title: ClipboardButton
Published: March 9, 2021
Last modified: October 14, 2026

---

# ClipboardButton

## In this article

 * [Usage](https://developer.wordpress.org/block-editor/reference-guides/components/clipboard-button/?output_format=md#usage)
 * [Props](https://developer.wordpress.org/block-editor/reference-guides/components/clipboard-button/?output_format=md#props)
    - [className](https://developer.wordpress.org/block-editor/reference-guides/components/clipboard-button/?output_format=md#classname)
    - [text](https://developer.wordpress.org/block-editor/reference-guides/components/clipboard-button/?output_format=md#text)
    - [onCopy](https://developer.wordpress.org/block-editor/reference-guides/components/clipboard-button/?output_format=md#oncopy)
    - [onFinishCopy](https://developer.wordpress.org/block-editor/reference-guides/components/clipboard-button/?output_format=md#onfinishcopy)
    - [Inherited props](https://developer.wordpress.org/block-editor/reference-guides/components/clipboard-button/?output_format=md#inherited-props)

This component is deprecated. Please use the `useCopyToClipboard` hook from the `@
wordpress/compose` package instead.

With a clipboard button, users copy text (or other elements) with a single click
or tap.

![Clipboard button component](https://i0.wp.com/wordpress.org/gutenberg/files/2019/
07/clipboard-button-2-1.png?ssl=1)

## 󠀁[Usage](https://developer.wordpress.org/block-editor/reference-guides/components/clipboard-button/?output_format=md#usage)󠁿

    ```language-jsx
    import { useState } from 'react';
    import { ClipboardButton } from '@wordpress/components';

    const MyClipboardButton = () => {
        const [ hasCopied, setHasCopied ] = useState( false );
        return (
            <ClipboardButton
                variant="primary"
                text="Text to be copied."
                onCopy={ () => setHasCopied( true ) }
                onFinishCopy={ () => setHasCopied( false ) }
            >
                { hasCopied ? 'Copied!' : 'Copy Text' }
            </ClipboardButton>
        );
    };
    ```

## 󠀁[Props](https://developer.wordpress.org/block-editor/reference-guides/components/clipboard-button/?output_format=md#props)󠁿

The component accepts the following props:

### 󠀁[className](https://developer.wordpress.org/block-editor/reference-guides/components/clipboard-button/?output_format=md#classname)󠁿

The class that will be added to the classes of the underlying `<Button>` component.

 * Type: `string`
 * Required: no

### 󠀁[text](https://developer.wordpress.org/block-editor/reference-guides/components/clipboard-button/?output_format=md#text)󠁿

The text that will be copied to the clipboard.

 * Type: `string`
 * Required: yes

### 󠀁[onCopy](https://developer.wordpress.org/block-editor/reference-guides/components/clipboard-button/?output_format=md#oncopy)󠁿

The function that will be called when the text is copied.

 * Type: `() => void`
 * Required: yes

### 󠀁[onFinishCopy](https://developer.wordpress.org/block-editor/reference-guides/components/clipboard-button/?output_format=md#onfinishcopy)󠁿

The function that will be called when the text is copied and the copy animation 
is finished.

 * Type: `() => void`
 * Required: no

### 󠀁[Inherited props](https://developer.wordpress.org/block-editor/reference-guides/components/clipboard-button/?output_format=md#inherited-props)󠁿

Any additional props will be passed the underlying `<Button/>` component. See the
[Button](https://developer.wordpress.org/block-editor/reference-guide/components/button/#props)
component for more details on the available props.

First published

March 9, 2021

Last updated

October 14, 2026

Edit article

[ Improve it on GitHub: ClipboardButton ](https://github.com/WordPress/gutenberg/edit/trunk/packages/components/src/clipboard-button/README.md)

[  Previous: CircularOptionPicker](https://developer.wordpress.org/block-editor/reference-guides/components/circular-option-picker/)

[  Next: ColorIndicator](https://developer.wordpress.org/block-editor/reference-guides/components/color-indicator/)