Skip to main content
Question

Applying Color Variable to an Instance or Layer

  • January 13, 2024
  • 1 reply
  • 286 views

Bradley_Kounter

Theres a ton of API’s im finding on creating variables, adding modes, etc. But I have a complicated workflow of:

Importing a component (instance)
Grabbing a local variable from a collection
Targeting a layer and then applying that local variable to it

Ive been trying to for hours use the boundVariableColor whatever method to accomplish this and keep either getting:

copyColor.Type has to equal “SOLID” which it does, or “expected a node and got a string instead”. Am i missing something? Is this even possible?

This topic has been closed for replies.

1 reply

y_toku
Figmate
  • Community Support
  • January 16, 2024

Hey there,

We have a code sample for how to apply color variables to a node here:
https://www.figma.com/plugin-docs/working-with-variables/#example-binding-a-variable-to-a-node-or-style.

Also, clone() is defined here:
https://www.figma.com/plugin-docs/editing-properties/#the-how

Could you please take a look at it? If that doesn’t help, please feel free to reply on this.

Thanks,
Toku