search Esc

Copy to Clipboard

Click-to-copy utility for any element. Works with button classes you already know — add data-lp-component="copy". On success the icon swaps to a check and a green Copied! bubble rises above the trigger; on failure it flashes red.

Basic copy button

Compose with existing lp-btn classes. Pass the payload via data-lp-text.

Copy from input

Point data-lp-target at any input by CSS selector; its .value is what gets copied.

Inline copy

Wrap the token and button in .lp-copy-inline. Default: the button fades in on hover/focus. Add .lp-copy-inline-show to keep it always visible at 60% opacity.

Hover the code to reveal the button — your discount code is SAVE20 .

Always-visible variant — your order ID is ORD-2026-ABC123 .

Target shortcuts

data-lp-target also accepts three keywords in addition to any CSS selector:

  • self — copies the trigger's own text (e.g. a chip whose label is the payload)
  • parent — copies the trigger's parent element text
  • previous — copies the immediately preceding sibling (used in the inline example above)
Button sizes

Copy triggers inherit the standard xs, sm, default, and lg size classes.

xs sm default lg
Button variants

Copy triggers work with every button variant — ghost is the most common for tight layouts.

Practical examples

Real-world composition — no extra CSS, just existing lp-* components.

API keys
Public key
pk_live_abc123xyz789
Color codes
#1a73e8
#34a853
#ea4335
Code snippet with header
code JavaScript
const greeting = "Hello, world!";
console.log(greeting);
Tracking information
local_shipping
Tracking number
1Z999AA10123456784
Custom feedback text & duration

Override with data-lp-success-text, data-lp-error-text, data-lp-feedback-duration (ms), or suppress the bubble with data-lp-show-feedback="false".

JavaScript API

Every trigger auto-initializes from its data-lp-component attribute. For programmatic control, grab the instance with Launchpad.Copy.find(el) or .create(el), then call .copy().

Listening to events

Each successful copy dispatches a bubbling lp:copy:copied event carrying detail.text; failures emit lp:copy:error with detail.error.

— no events yet —
Configuration options

Every option can be set via the matching data-lp-* attribute (camelCase → kebab-case) or passed to Launchpad.Copy.create(el, options).

OptionData attributeDefaultDescription
textdata-lp-textnullDirect string to copy. Takes precedence over target.
targetdata-lp-targetnullCSS selector, or one of self / parent / previous. Inputs copy .value, selects copy the selected option text, otherwise textContent.
feedbackDurationdata-lp-feedback-duration2000Milliseconds the success/error state persists.
successIcondata-lp-success-icon"check"Material Symbols icon name shown during success feedback (empty string disables swap).
successTextdata-lp-success-text"Copied!"Bubble text on success.
errorTextdata-lp-error-text"Failed"Bubble text on failure.
showFeedbackdata-lp-show-feedbacktrueToggle the floating bubble. Icon swap and state class still run.