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

What is Framer? Join the Community
Return to index
Sigurd Tapio Mannsåker
Posted Feb 04 - Read on Facebook

I'm fairly new to Framer – what's the simplest way to target nested layers? The only way I've found so far is sketch.motherLayer.getSubLayersByName('childLayer')[0].getSubLayersByName('grandChildLayer')[0] if I don't want my code to break if their index changes (otherwise subLayers[0].subLayers[3].etc works fine). Gets a bit tedious :) Any built in helper functions, or ways to filter all layers in all groups by name so all I have to do is ensure my Sketch groups have unique names?

3 Comments

Ben Rodenhäuser

Not sure if this helps answer your question, but regardless whether buttonA is a top-level layer or nested like in interface > buttons > buttonA, you can address it simply using sketch.buttonA.

Andreas Wahlström

Seems like you solved it! Still, you can try this module I wrote which lets you target layers using CSS-ish selectors: https://github.com/awt2542/Select-for-Framer
eg. Select('motherLayer grandChildLayer')

Sigurd Tapio Mannsåker

Thanks guys, all very helpful advice :) For whatever reason I can't see the globalLayers utility at framerjs.com/docs/ – nice time saver!

Read the entire post on Facebook