Skip to main content
shaina1
New Participant
March 30, 2023
Question

Getting list of component property combinations

  • March 30, 2023
  • 7 replies
  • 664 views

From an instance node, I’m trying to move up the tree up to the componentSetNode, then to each componentNode so I can grab every valid combination of component properties (sometimes components have unused combinations).
When I run . componentPropertyReferences on the componentNode, I’m getting an empty object back.

Is there another way to tackle this?

This topic has been closed for replies.

7 replies

tank666
March 31, 2023

Here is how the componentPropertyReferences property is described in the documentation:

All component properties that are attached on this node. A node can only have componentPropertyReferences if it is a component sublayer or an instance sublayer. It will be null otherwise. The value in the key-value pair refers to the component property name as returned by componentPropertyDefinitions on the containing component, component set or main component (for instances).

Therefore, to get the componentPropertyReferences, you need to traverse the tree of children, its children’s children, etc.

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
shaina1
shaina1Author
New Participant
March 31, 2023

Traversing the tree doesn’t show anything under componentPropertyReferences for components under a componentSet. And componentPropertyDefinitions isn’t what I’m looking for.

tank666
March 31, 2023

Have you traversed the children tree inside the ComponentNode?

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
shaina1
shaina1Author
New Participant
March 31, 2023

Yes I have, i went from instance → componentNode → componentSetNode → componentNode

tank666
March 31, 2023
InstanceNode.mainComponent.parent.children[0].children[0] // etc.
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
shaina1
shaina1Author
New Participant
March 31, 2023

Why would I go through each element inside a component node? Thats extremely inefficient.

tank666
March 31, 2023

Only there you can get a non-null componentPropertyReferences. I wrote about this from the very beginning.

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