Is there any way to bind variables to my gradient with Plugin API?
We got gradientStops and boundVariables for them, but I can’t see any way to set bound variables for it.
Regarding binding variables to gradients using the Figma Plugin API, currently, there isn’t a direct method similar to setBoundVariableForPaint() for gradient stops. The API supports gradientStops and boundVariables, but as you mentioned, setting bound variables specifically for gradient stops isn’t available yet.
If you’re looking to dynamically control gradient stops via plugins, consider exploring workarounds such as manipulating gradient stop positions programmatically or using preset gradients that your plugin can switch between based on variables.
As for future updates, it’s worth keeping an eye on Figma’s API documentation or developer forums for any announcements or additions to support gradient stop bindings more directly.
For setting variables inside complex objects like fills, effects, etc…, you can always create a new object with the bound variables inside and apply it to the node, e.g.
node.fills = // your new object
// or
node.effects = // your new object
To more easily understand the object structure, it helps to create the node you want manually in the UI and then inspecting the desired node properties.
There are a number of helpers (Working with Variables | Plugin API) to help you create variable references inside these complex objects but those are just helpers and not strictly necessary as long as you have an object with the correct structure. For gradient paints, setBoundVariableForPaint() doesn’t work because you can have different variables for each color stop.