Skip to main content
Question

How to set color styles to a variable collection in another file?

  • February 8, 2024
  • 1 reply
  • 572 views

Neel_Sara

I’m programmatically updating color styles to point to variables. This works great when the variable collection is in the current file and I can use getLocalVariableCollections. However, for my use case the variable collection I want to use lives in a separate library file from the file I’m trying to update with variables. I’ve tried using getVariableCollectionById by using the ID of the variable collection in the other file, but my console logs “The variable collection with id “<ID>” does not exist” - I’m assuming it’s only checking the current file for a collection with this ID, which is why it’s saying not found.

You can manually set color styles in the UI to variables from another library, so how can I do this via the plugin API?

This topic has been closed for comments

1 reply

tank666
  • 4863 replies
  • February 9, 2024

To use variables from a library, you need to import it first. Please read the documentation:

figma.com

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