Skip to main content
Nidhin_Kuttikkattu_Rajeevan
Active Member
October 20, 2023
Question

List down all the possible attributes in figma property in plugin

  • October 20, 2023
  • 16 replies
  • 1040 views

Hi Could I ask a question?

I have a componet called Fruit. I created an intance of Fruit in my Figma document. It has properties like colour, origin
Suppose possible options for colour are Green, Red, Orange, DarkRed
Suppose possible options for origin are Indian,Netherland,England,France

It will come under variant properties. So in my plugin, I will set colour=Green using setProperties API.

I read this property Green Blue etc from a txt file. So sometimes there is a chance that Green is green(Capital letter,small letter issue) and Figma plugin throw error if there is no exact match. So in plugin I would like to read all the possible combinations of colour before throwing an exception. How can I do that?

For example, if I click fruit instance node, can I iterate through its properties like colour and origin then list all available values of colour and origin to a string array? So before I assign colour = inputFromTextFile, I can check if InputFromTextFile is Green or green.

This topic has been closed for replies.

16 replies

Nidhin_Kuttikkattu_Rajeevan
Active Member
October 20, 2023

Do you think it is iteratable? VariantOptions ?

tank666
October 20, 2023

I do not understand your question. Are you asking if arrays are iterable? Yes, arrays are iterable objects.

developer.mozilla.org
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
Nidhin_Kuttikkattu_Rajeevan
Active Member
October 20, 2023

Oh no 🙂 Come on…

It is returning as
{
‘PropertyName 1’: {
type: ‘VARIANT’,
defaultValue: ‘Default’,
variantOptions: [‘Default’, ‘Variant 2’, ‘Variant 3’, ‘…’]
},
‘PropertyName 2’: {
type: ‘VARIANT’,
defaultValue: ‘True’,
variantOptions: [‘True’, ‘False’]
},

}
as you mentioned, I need to iterate each property in the returned data and go to variantOptions… So I am stil trying to know how to
navigate to VariantOptions from InstanceNode.mainComponent.parent.componentPropertyDefinitions

tank666
October 20, 2023
ComponentSetNode.componentPropertyDefinitions['PropertyName'].variantOptions
developer.mozilla.org
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
Nidhin_Kuttikkattu_Rajeevan
Active Member
October 20, 2023

Ah thanks,

It works now. Cheers.

December 4, 2023

tks!!You help me a lot!