Skip to main content
chriskuhrt
New Participant
December 5, 2024
Solved

Add Components (+variants) via my own Plugin

  • December 5, 2024
  • 5 replies
  • 288 views

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

This topic has been closed for replies.
Best answer by tank666

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

5 replies

tank666
tank666Answer
December 5, 2024

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
UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank
chriskuhrt
New Participant
December 5, 2024

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

chriskuhrt
New Participant
December 25, 2024

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.

tank666
December 25, 2024
node.expanded = false

Please refer to the developer documentation:

figma.com
UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank
chriskuhrt
New Participant
December 25, 2024

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).