Skip to main content
September 19, 2023
Solved

How to get the typography's name

I’m currently creating a codegen plugin and I need to get the , here is what I mean by “typography’s name” in edit mode:
image

I can get all the other data but not its name, which is what I actually need 🥲

This topic has been closed for replies.
tank666
tank666Solution
September 19, 2023

It’s because you didn’t get the style. To get the style you need to use the getStyleById method.

figma.com
UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank

4 replies

tank666
September 19, 2023

Get the name of the text style.

figma.com
UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank
September 19, 2023

Thanks for the quick reply but they are not actually the same, name seems to refer to the node’s name as seen above the node and in the console (node.name) on this screenshot:

But i’m actually looking for the typography’s name, Desktop/Headings/H4 in the screenshot

tank666
tank666Solution
September 19, 2023

It’s because you didn’t get the style. To get the style you need to use the getStyleById method.

figma.com
UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank
September 19, 2023

Oh I see, thanks a lot!

For anyone stumbling upon this issue, here’s a minimal example:

figma.codegen.on("generate", async (e: CodegenEvent) => {
  const node = e.node;

  if (node.type === "TEXT") {
    console.log(figma.getStyleById(node.textStyleId).name);
  }
})