Create Your Own Relume Style Library
Many Webflow users have posted tutorials on how to create your own copy/paste library similar to Relume.io, but one issue that keeps showing up is Webflow's 5,000 character limit on embeddable code, but we can avoid the limit by using custom attributes!
CMS STRUCTURE
Before we get down to the steps you'll need a CMS Collection, with a "text field", call it something like "JSON Data". After you've added that, let's move on.
STEP. 1
Add the following script to your Webflow pages closing </body> tag. I won't bore you with how this works, just know that it does!
1 <script>
2 document.querySelectorAll('.object-clone-btn').forEach(item => {
3 item.addEventListener('click', event => {
4 event.preventDefault();
5 let data = item.dataset.json; // Get JSON from button's data-json attribute
6
7 console.log("Button clicked");
8 document.addEventListener('copy', event => {
9 console.log("Object copied");
10 if (event.clipboardData) {
11 event.clipboardData.setData('application/json', data);
12 } else if (window.clipboardData) {
13 window.clipboardData.setData('application/json', data);
14 }
15 event.preventDefault();
16 }, true);
17 document.execCommand('copy');
18 })
19 })
20 </script>
STEP. 2
Next we need a button in our Component Collection Item, give it a class "object-clone-btn". It doesn't have to be the only class, as in my example below I simply added it as a combo-class.
object-clone-btn
STEP. 3
On the afore mentioned button we're going to add a custom attribute! This is where we bypass the 5000 Webflow character limit.
With your button selected, open the "Settings" panel on the right, scroll down to Custom Attributes and we're going to add one using the plus icon.
Name it "data-json"
And the value we're going to attach is from the CMS Field we named JSON Data, pictured below.
STEP. 4
Publish it! You're done, go test it.
Up your Webflow game by adding custom CSS properties.