Skip to main content
const paintStyles = figma.createPaintStyle();
paintStyles.name = semanticStyle;
const paints = [{
blendMode : 'NORMAL',
color : rgb,
opacity : 1,
type : 'SOLID',
visible : true
}];
paintStyles.paints = paints;

In this above logic, when trying to set paintStyles. paints = paints, I get the error-

figma_app.min.js.br:4 Error: in set_paints: Expected “paints.s0].type” to be one of the allowed values for this property

at PaintStyle.set_paints nas paints] (eval at (eval at createScopedEvaluatorFactory


Based on this documentation, I see SOLID is a valid type.


I recently started working with Figma API so still new and learning. Thanks in advance!

You’ll find the types here: SOLID, IMAGE, GRADIENT_LINEAR, GRADIENT_RADIAL, GRADIENT_ANGULAR, GRADIENT_DIAMOND


figma.com

Thanks @ntfromchicago . I realized what was causing the problem and giving that error in my case. It turns out that when you set paints property of PaintsStyles object, you should only be passing an object with type and color properties. If you add blendMode and visible then it throws the error that I was seeing. It would be helpful though if the error was more meaningful. In this case, the error message was completely misleading. Here is the solution that works-


const paintStyles = figma.createPaintStyle();
paintStyles.name = semanticStyle;
const paints = {
color : rgb,
type : 'SOLID'
};
paintStyles.paints = [paints];

Thank you for your response.


Reply