Skip to main content

So I’m already able to add Colors, Frames with a Grid, and an Image via my plugin to a new Figma file.


But is there an easy way to add a Component with variants etc?


These would be my need:




Is it possible to build the component in Figma, extract the relevant JSON data, and seamlessly integrate it into my plugin? Or do I need to recreate the component entirely from scratch in code? via Shared Node Properties | Plugin API

If I understand you correctly, you can use the figma.createComponentFromNode(node) method to create a component from an existing node, and then combine them as component set variants using:


figma.com

This could be it! How did I missed that?! I’ll let you know if it works as hoped. - Thx!


It worked! Thanks!


It seems that the layers panel always expand after creating the components via the API. Apparently there is no way to collapse it back again?!, accept manually of course.


node.expanded = false

Please refer to the developer documentation:

figma.com

thank you for your patience despite my inability…

i was too focused on the layer panel and its wording and didn’t think about the fact that i might be looking more at the “children” (nodes).


Reply