Figma plugin API to add/update local styles or variables

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?

1 Like

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.

1 Like

Thank you :slight_smile: