Handle variants via api

Hello, I am new to Figma and I try to create a new plugin. One of the functionalities of the plugin is to switch the variant of a component. Is it possible via the API?

1 Like

In the API, each variant is simply a regular component. So to switch them, you simply need to change the mainComponent of an instance to a different component. But you will lose all overrides. :slightly_frowning_face:

1 Like

Code example here: How to update single component attribute or variant via plugin? - #2 by Gleb