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
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>
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.
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
Lorem ipsum
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.















