Figma.mixed

I’m trying to retrieve the Style’s name for the fill color of text.

      let styleId = textNode.fillStyleId
      let styleName = figma.getStyleById(styleId).name

I get an error:
Argument of type ‘string | unique symbol’ is not assignable to parameter of type ‘string’.
Type ‘typeof figma.mixed’ is not assignable to type ‘string’.

I’ve tried defining styleId as a unique symbol (among other things), but basically keep running into the variable type conflict.

Any tips?

You need to check if the style is mixed and do something if it is like using the range functions to get styles of separate characters. TextNode · Figma Developers

let styleId = textNode.fillStyleId
if (styleId === figma.mixed) {
  // process each character individually 
  // or simply get the color of the first character
  styleId = textNode.getRangeFillStyleId(0, 1) as string
}
let styleName = figma.getStyleById(styleId).name
1 Like

Thank you, this helped a bunch