Skip to main content
Solved

Attach a boolean property to a single variant? via Plugin API

  • December 25, 2024
  • 2 replies
  • 85 views

chriskuhrt

Hi, I’m trying to create a component through a plugin that has four variants, and each variant includes a boolean property. Couldn’t really find something?!

For fun, I tried giving the task to ChatGPT o1.
Beside some “code” it also wrote:

Note: In Figma’s newer component properties system, you can directly attach a boolean property to a single variant (so that you don’t need separate variants for icon on/off). However, the Plugin API (as of now) typically requires you to create multiple variant nodes if you want a boolean property to appear in the properties panel.

Is this correct?

Best answer by tank666

From the above, I still don’t understand whether you need a variant property with a boolean value or a component’s boolean property. In either case, you can use the addComponentProperty method, but for the first case, the value must be a string type, and for the second—a boolean type.

I don’t want to discuss the crap that AI bots write, but you can add a component property to ComponentNode or ComponentSetNode.

Also:

View original

2 replies

tank666
  • 4873 replies
  • Answer
  • December 25, 2024

From the above, I still don’t understand whether you need a variant property with a boolean value or a component’s boolean property. In either case, you can use the addComponentProperty method, but for the first case, the value must be a string type, and for the second—a boolean type.

I don’t want to discuss the crap that AI bots write, but you can add a component property to ComponentNode or ComponentSetNode.

Also:


chriskuhrt
  • Author
  • New Member
  • 10 replies
  • December 26, 2024

Thanks for linking the other threads! It works.

That one helped:


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings