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?


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.

Callil Capuozzo

Here's a trick:


put this under your import and each layername is now targetable without having to prepend 'sketch'. Just target layerA instead of sketch.layerA

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:
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 – nice time saver!

Read the entire post on Facebook