Ajouter

Lorem ipsum

Lorem ipsum

Design

5 views

4 min

How to Copy Text to the Clipboard in Webflow

Learn how to add a “Copy” button in Webflow to copy text to the clipboard with the Clipboard API.

In this tutorial, Sandro, cofounder of Gemeos Webflow agency, shows you how to add a “Copy” button to copy text to the clipboard from Webflow.

Example

Click to copy

https://gemeosagency.com/academie/copy-to-clipboard-webflow

ID / ClassElementRole
copy-textText Block or DivContent to copy
copy-btnLink Block or ButtonTrigger button
copy-feedbackText BlockConfirmation message

1. Create the elements in Webflow

Create a Text Block with the ID copy-text containing the text to copy. Add a button with the ID copy-btn. Optional: add a Text Block with the ID copy-feedback showing “Copied!” with display set to none by default.

2. Add this script in the <body>

document.getElementById('copy-btn').addEventListener('click', function() {
const text = document.getElementById('copy-text').textContent;
navigator.clipboard.writeText(text).then(function() {
const feedback = document.getElementById('copy-feedback');
if (feedback) {
feedback.style.display = 'block';
setTimeout(function() { feedback.style.display = 'none'; }, 2000);
}
});
});

3. Publish and test

Click the button: the text is copied and the “Copied!” message appears for 2 seconds. If you want to copy an input field, replace .textContent with .value.

good to know

The navigator.clipboard.writeText() API requires HTTPS to work. In Webflow preview (on webflow.io), it works. On a custom domain, make sure your SSL certificate is active. On older browsers without Clipboard API support, use document.execCommand('copy') as a fallback.

Conclusion

The copy button improves UX for technical content. Use cases:

  • Copy a promo code on a landing page
  • Copy a code snippet in a tutorial
  • Copy a referral link

Published on

You might be interested in these tutorials

Similar tutorials

SEO / GEO

5 min read

5 views

How to Set Up a Redirect in Webflow? (2026)

Updated on 19.12.2025 by Sandro DA SILVA

SEO / GEO

5 min read

5 views

Add structured data to your Webflow site?

Updated on 21.08.2025 by Sandro DA SILVA

No-code

5 min read

5 views

How to Obfuscate a Link in Webflow

Updated on 23.04.2025 by Sandro DA SILVA

Let’s f*****G GO !!

Ready to launch
Your business?

Alexandre

Max

Enora

Bryan

Cannelle

Tiphaine

You'll :heart: our collaboration...