Skip to main content
Pavel_Kiselev
Power Member
June 27, 2023
Question

How to use setBoundVariableForPaint

  • June 27, 2023
  • 12 replies
  • 1781 views

I would appreciate some guidance on figma.variables. setBoundVariableForPaint method.

figma.com

I would like to run a simple script to bind a variable to the existing style. This is what I tried

// get a style ref
let style = figma.getLocalPaintStyles()[0];
// get a var ref
let variable = figma.variables.getVariableById("VariableID:1:53");
// bind?
figma.variables.setBoundVariableForPaint(style.paints[0], 'color', variable);

It returns a solid paint indeed, however, it has no effect on a given style. Confusing…

This topic has been closed for replies.

12 replies

Pavel_Kiselev
Power Member
August 18, 2023

And another one that goes other way around - it takes local colour styles and makes variables out of them

tinaciousdesign
September 24, 2024

This is great! I had been creating blank colour variables, turns out I was missing setValueForMode. Thanks for this!