Skip to main content
santferal
New Participant
Oct 16, 2024 8:00 AM UTC
Question

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

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
Oct 16, 2024 8:42 AM UTC

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
Oct 16, 2024 9:25 AM UTC

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
Oct 16, 2024 9:43 AM UTC

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
Oct 16, 2024 11:19 AM UTC

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

Gleb
Power Member
Oct 16, 2024 11:58 AM UTC

Here you go:

const importedStyle = await importStyleByKeyAsync("abcde")

(replace abcde with your actual style key)

santferal
santferalAuthor
New Participant
Oct 17, 2024 4:50 PM UTC

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
Oct 17, 2024 5:04 PM UTC

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