Trying to implement https://clipboardjs.com/

Hi I am trying to implement click to copy text to clip board.
I cloned and looked at this project:
https://preview.webflow.com/preview/copy-clipboard?utm_source=copy-clipboard&preview=5d01f60941fd7be31d23ea44e25f0b31

I am using something similar in library> color

But in the above project they have an explicit html embed button to copy text

I want the entire color itself to be tappable and send the hexcode to clipboard.js
right now when i use custom attribute it is simply sending the word “hexcode” and parsing it through the script file.

is there a way to point to a specific entry in a collection via custom attributes? rather than just send the text literally?
41%20AM


Here is my site Read-Only: Webflow - Vision
(how to share your site Read-Only link)

Replace

var clipboard = new Clipboard('.btn');

with

var clipboard = new Clipboard('.btn', {
    text: trigger => trigger.querySelector('.colorhex').innerText
});

Also, feel free to contact me for further code help and/or customization of third-party plugins.

Thanks a mil. @samliew
Works perfectly now.