Hi everyone,
I’m developing a Figma plugin that extracts design properties from selected nodes, including text styles and color tokens.
For text styles, I successfully retrieve the applied style using:
const textStyle = figma.getStyleById(node.textStyleId);
This works great for identifying and mapping text styles.
However, I can’t find a way to get the color variable applied to a node. When inspecting node.fills, I only see the RGB color, but not the token assigned in Figma variables.
Example:
In Figma, the text color is set using a variable:
color: var(--color-foreground-primary, #000);
But when I check node.fills in the plugin API, I only get:
{
type: "SOLID",
color: { r: 0, g: 0, b: 0 }
}
I tried checking node.boundVariables, but it doesn’t seem to return color-related variables.
Questions:
1️⃣ Is there any way to get the applied color variable name (e.g., "color-foreground-primary") in a Figma plugin?
2️⃣ Can we extract this information from boundVariables, fills, or another API method?
If there’s a workaround, I’d love to hear it! 🚀 Thanks in advance.