gomakethings.com
How to build a copy-to-clipboard HTML Web Component
Yesterday, we looked at how to copy items to a user’s clipboard with JavaScriprt. Today, we’re going to turn that into an HTML Web Component.
Let’s dig in!
The Custom Element For this Web Component, let’s use a <copy-to-clipboard> element.
<copy-to-clipboard> </copy-to-clipboard> With the HTML Web Component approach, we start with HTML and enhance it rather than rendering all the things with JavaScript.
Let’s add a <button> with our desired text inside the custom element.