Skip to main content
santferal
New Participant
October 16, 2024
Question

How can i import Styles from a remote lobrary into the plugin interface?

  • October 16, 2024
  • 7 replies
  • 175 views

I am having problems importing styles from a remote library. I can’t get them to display in a div inside the plugin interface.
I had no problem with the variables but now I can’t import them correctly. Because I imagine that they work in a different way but I can’t find the documentation.
Thank you very much in advance.

This topic has been closed for replies.

7 replies

tank666
October 16, 2024

What’s the problem, exactly? Get the style value, send it to the UI, convert that value to the format you need, and apply it to your div.

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
santferal
santferalAuthor
New Participant
October 16, 2024

Yes, I cant get the values of the styles to apply it on the div in the plugin interface. ( the plugin is running on a file with out styles and it has only styles from a remote library)

tank666
October 16, 2024

Use the getStyleByIdAsync(id) method to get the desired style data (or import styles using importStyleByKeyAsync(key), or use the REST API).

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
santferal
santferalAuthor
New Participant
October 16, 2024

Thanks @tank666 !!
Could you show me an example functional code to have all the remote style import link complete ?

Gleb
Power Member
October 16, 2024

Here you go:

const importedStyle = await importStyleByKeyAsync("abcde")

(replace abcde with your actual style key)

santferal
santferalAuthor
New Participant
October 17, 2024

I dont have a defined style key beause wll depend on the libraries that will be linked to the file. So for an universal case how should be that part of the key ?

tank666
October 17, 2024

So get style keys from remote libraries using REST API or by opening each library file and using local styles getting methods using Plugin API.

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