Skip to main content

Hello,

Trying to figure out how to retrieve the COMPONENT_SET to which a component/variant belongs to.


“masterComponent” will give me the name for the variant… also the type is INSTANCE, what is the best way do I identify that an INSTANCE is also variant?

instance.mainComponent.parent

Yeah @Gleb, it will be a combination of:


if (element.type === 'INSTANCE' + :has(variantProperties)) {
get (instance.mainComponent.parent.id)
}

Something like that…


One observation the “instance.mainComponent.parent” will be of type “COMPONENT”… but if I click the component wrapper itself for the variants the type is “COMPONENT_SET”… not sure if that is by design, but it would be good if they match




.


Thanks


That’s weird. Maybe it’s a bug in Node Inspector plugin? Have you tried using the console?


figma.currentPage.selectiont0].mainComponent.parent.type

For me this yields "COMPONENT_SET" when the selected object is the variant set instance.


You are right, I will reach out to the plugin developer, thanks


Reply