This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Jason Sparks
Posted Jul 16 - Read on Facebook

Is there an easy way to design a layer in the design tab and then in code convert that layer to a class? e.g I design a simple button, target it in code so it appears as my-btn, and then somehow make a MyBtn class (with all the properties of my-btn) so I can have multiple instances of the MyBtn class throughout my design? If it’s not easy - any suggested work-
arounds would be appreciated.


Brent Riddell

Sure! There are some issues but its possible, check out this thread:

Jon Madison

Strategy is this:

create a class or function that:

Takes that target layer as input
Does a .copy() of the object and returns it

In my case I’m actually doing an Object.assign of the copy.

In that function also recursively grab the layer names and recreate the hierarchy on the Layer you’re gonna return.

Hope that very high level guidance made sense and tides you over until the Framer guys just make design and code Layers the same thing (ahem 🙂

Read the entire post on Facebook