Copy button
Enable users to instantly copy text or content to their clipboard with a single click.
#Examples
#Basic Usage
A standard button labeled "Copy" (not localized). Ideal for short, inline content where the copy action is self-evident. For example, use this variant to copy a sharable link within an action bar. The tooltip defaults to appearing above the button.
Interaction:
- Default: No tooltip.
- Hover: Tooltip: "Click to copy".
- Click: Content copied, tooltip: "Copied!".
- Post-Click: Button and tooltip return to default.
<CopyButton toCopy={"Text to be copied"} tooltip="Click to copy" tooltipCopied="Copied!">
Copy
</CopyButton>
#Custom Tooltip Placement
Copy Buttons display feedback in a tooltip. The tooltip is not fixed to the button. Customize its position to ensure it's always fully visible, especially in areas with limited space above the button.
<CopyButton
variant="primary"
toCopy="Text to be copied"
tooltip="Click to copy"
tooltipCopied="Copied!"
tooltipPlacement="right"
>
Copy
</CopyButton>
#With Icon
The button displays a customizable copy icon (e.g., two overlapping squares) instead of text. Helpful when space is limited, or for visual emphasis of the copy action.
<CopyButton
variant="borderless"
toCopy="Text to be copied"
tooltip="Click to copy"
tooltipCopied="Copied!"
>
<Icon>
<IconCopy />
</Icon>
</CopyButton>
#Properties
Property | Description | Defined | Value |
---|---|---|---|
toCopyRequired | string | ||
tooltipRequired | string | ||
tooltipCopiedRequired | string | ||
childrenOptional | element | ||
tooltipPlacementOptional | "bottom" | "bottom-end" | "bottom-start" | "left" | "left-end" | "left-start" | "right" | "right-end" | "right-start" | "top" | "top-end" | "top-start" | ||
variantOptional | "borderless" | "ctaDefault" | "ctaPrimary" | "ctaSecondary" | "default" | "destructive" | "primary" | "secondary" | ||
data-observe-keyOptional | string Unique string, used by external script e.g. for event tracking | ||
classNameOptional | string Custom className that's applied to the outermost element (only intended for special cases) | ||
styleOptional | object Style object to apply custom inline styles (only intended for special cases) |
#Guidelines
#Best practices
#Do not use when
#Accessibility
Explore detailed guidelines for this component: Accessibility Specifications