Skip to main content

ClipboardItem

Enables clipboard functionality when its id is referenced by the activateTarget property of a Button, Pressable, or Link component. When activated, it copies the text to the clipboard and displays a Tooltip confirmation.

ClipboardItem is a non-rendering component.

string

A unique identifier for the component.

Anchor to onCopy
onCopy
() => void

Callback run when the copy to clipboard succeeds.

Anchor to onCopyError
onCopyError
() => void

Callback run when the copy to clipboard fails.

string
Default: ''

Plain text to be written to the clipboard.

Examples
import {
reactExtension,
Button,
ClipboardItem,
} from '@shopify/ui-extensions-react/checkout';

export default reactExtension(
'purchase.checkout.block.render',
() => <Extension />,
);

function Extension() {
return (
<>
<Button
activateTarget="discount-code"
activateAction="copy"
>
Copy discount code
</Button>
<ClipboardItem
text="SAVE 25"
id="discount-code"
/>
</>
);
}

Preview

Was this page helpful?