Skip to main content

Hi, I know we can get all the local styles using the plugin api Figma.getLocalPaintStyles(). But is there any API to update or add localStyles? Basically I want to get all the colors from the selected frames using Figma.getSelectionColors(). And then add the colors as variables or color styles. How do I add/update variables or colorstyles using any plugin API?

figma.com

Thanks. 2 more questions:



  1. Is there any similar plugin API to create local style as well?

  2. Can I replace a specific color fill with the corresponding variable/localStyle with the same color hexcode or rgb value using a plugin API?



First link


Okay. I think I found it. createPaintStyle(). Thanks


Yes, the link goes to createPaintStyle method.



Yes, absolutely. Just set the fillStyleId or stroke whatever other field you need.


Thank you 🙂