Clipboard item
The clipboard item component copies text to the buyer's clipboard when triggered by another component. Use clipboard item alongside button or link to let buyers copy discount codes, order numbers, or referral links in one click.
Clipboard item connects to a trigger element through the commandFor and id attribute pairing. It fires copy and copyerror events to confirm the result of the copy operation.
Clipboard item doesn't render any visible UI on its own. Pair it with a visible trigger such as button or link.
Supported targets
- purchase.
checkout. actions. render-before - purchase.
checkout. block. render - purchase.
checkout. cart-line-item. render-after - purchase.
checkout. cart-line-list. render-after - purchase.
checkout. contact. render-after - purchase.
checkout. delivery-address. render-after - purchase.
checkout. delivery-address. render-before - purchase.
checkout. footer. render-after - purchase.
checkout. header. render-after - purchase.
checkout. payment-method-list. render-after - purchase.
checkout. payment-method-list. render-before - purchase.
checkout. pickup-location-list. render-after - purchase.
checkout. pickup-location-list. render-before - purchase.
checkout. pickup-location-option-item. render-after - purchase.
checkout. pickup-point-list. render-after - purchase.
checkout. pickup-point-list. render-before - purchase.
checkout. reductions. render-after - purchase.
checkout. reductions. render-before - purchase.
checkout. shipping-option-item. details. render - purchase.
checkout. shipping-option-item. render-after - purchase.
checkout. shipping-option-list. render-after - purchase.
checkout. shipping-option-list. render-before - purchase.
thank-you. announcement. render - purchase.
thank-you. block. render - purchase.
thank-you. cart-line-item. render-after - purchase.
thank-you. cart-line-list. render-after - purchase.
thank-you. customer-information. render-after - purchase.
thank-you. footer. render-after - purchase.
thank-you. header. render-after
Supported targets
- purchase.
checkout. actions. render-before - purchase.
checkout. block. render - purchase.
checkout. cart-line-item. render-after - purchase.
checkout. cart-line-list. render-after - purchase.
checkout. contact. render-after - purchase.
checkout. delivery-address. render-after - purchase.
checkout. delivery-address. render-before - purchase.
checkout. footer. render-after - purchase.
checkout. header. render-after - purchase.
checkout. payment-method-list. render-after - purchase.
checkout. payment-method-list. render-before - purchase.
checkout. pickup-location-list. render-after - purchase.
checkout. pickup-location-list. render-before - purchase.
checkout. pickup-location-option-item. render-after - purchase.
checkout. pickup-point-list. render-after - purchase.
checkout. pickup-point-list. render-before - purchase.
checkout. reductions. render-after - purchase.
checkout. reductions. render-before - purchase.
checkout. shipping-option-item. details. render - purchase.
checkout. shipping-option-item. render-after - purchase.
checkout. shipping-option-list. render-after - purchase.
checkout. shipping-option-list. render-before - purchase.
thank-you. announcement. render - purchase.
thank-you. block. render - purchase.
thank-you. cart-line-item. render-after - purchase.
thank-you. cart-line-list. render-after - purchase.
thank-you. customer-information. render-after - purchase.
thank-you. footer. render-after - purchase.
thank-you. header. render-after
Anchor to PropertiesProperties
Configure the following properties on the clipboard item component.
- Anchor to idididstringstring
A unique identifier for the element. Use this to reference the element in JavaScript, link labels to form controls, or target specific elements for styling or scripting.
- Anchor to texttexttextstringstringDefault: ''Default: ''
Plain text to be written to the clipboard.
Rich text, HTML, and binary content aren't supported.
Anchor to EventsEvents
The clipboard item component provides event callbacks for handling user interactions. Learn more about handling events.
- Anchor to copycopycopyCallbackEventListener<typeof tagName>CallbackEventListener<typeof tagName>
A callback fired when the text is successfully copied to the clipboard. Use this to show a confirmation message or update the UI.
- Anchor to copyerrorcopyerrorcopyerrorCallbackEventListener<typeof tagName>CallbackEventListener<typeof tagName>
A callback fired when the copy to clipboard fails. Use this to display an error message or provide a fallback action.
CallbackEventListener
A typed event listener for custom element events. The listener receives a `CallbackEvent` with the correct `currentTarget` type for the associated custom element tag.
(EventListener & {
(event: CallbackEvent<TTagName, Event> & TData): void;
}) | nullCallbackEvent
An event type that narrows the `currentTarget` to the specific HTML element associated with the custom element tag. This provides type-safe event handling in callback listeners.
TEvent & {
currentTarget: HTMLElementTagNameMap[TTagName];
}Anchor to ExamplesExamples
Pair a button with a clipboard item so buyers can copy a discount code in one click. This example connects an
s-button to an s-clipboard-item using matching commandFor and id attributes.Copy a discount code with a button

html
Anchor to Copy an order number with a linkCopy an order number with a link
Trigger a clipboard copy from a link instead of a button for inline copy actions. This example pairs an s-link with an s-clipboard-item to copy an order confirmation number.html
Anchor to Copy a referral codeCopy a referral code
Display a referral code alongside a copy button so buyers can share it after purchase. This example shows the code as visible text with a secondary button connected to an s-clipboard-item.html
Anchor to Best practicesBest practices
- Use descriptive button text: Label the trigger with what's being copied, such as "Copy discount code" rather than just "Copy."
- Display the value being copied: Show the text content visually alongside the copy trigger so buyers know what they're copying.
- Listen for copy events: Use the
copyandcopyerrorevents to provide feedback, such as changing the button text to "Copied!" after a successful copy. - Keep text values short: Clipboard items work best with concise values like codes, IDs, and short URLs rather than long paragraphs.