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 textprevious— 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.
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
pk_live_abc123xyz789
Color codes
#1a73e8
#34a853
#ea4335
Code snippet with header
const greeting = "Hello, world!";
console.log(greeting);
Tracking information
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.
Configuration options
Every option can be set via the matching data-lp-* attribute (camelCase → kebab-case) or passed to Launchpad.Copy.create(el, options).
| Option | Data attribute | Default | Description |
|---|---|---|---|
text | data-lp-text | null | Direct string to copy. Takes precedence over target. |
target | data-lp-target | null | CSS selector, or one of self / parent / previous. Inputs copy .value, selects copy the selected option text, otherwise textContent. |
feedbackDuration | data-lp-feedback-duration | 2000 | Milliseconds the success/error state persists. |
successIcon | data-lp-success-icon | "check" | Material Symbols icon name shown during success feedback (empty string disables swap). |
successText | data-lp-success-text | "Copied!" | Bubble text on success. |
errorText | data-lp-error-text | "Failed" | Bubble text on failure. |
showFeedback | data-lp-show-feedback | true | Toggle the floating bubble. Icon swap and state class still run. |