ClipboardButton Edit
With a clipboard button, users copy text (or other elements) with a single click or tap.
Usage
import { ClipboardButton } from '@wordpress/components'; import { useState } from '@wordpress/compose'; 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> ); };