How can I create a design library and use it in a plugin, so when a user select a design, add it to their Figma project?
You first need to publish the file as a team library and then use the appropriate Plugin API methods.
-
figma.importComponentByKeyAsync(key)
; -
figma.importComponentSetByKeyAsync(key)
; -
figma.createComponent()
; -
ComponentNode.createInstance()
.
You can get some details in this thread: How access other file by Figma API.
Thank you for your help. I tried the solution and I got an error as below:
Cannot import component with key "..." since it is unpublished!!
Actually I’ve published it with a starter plan and it gives me this error. Should I purchase other plans?
With a Starter plan, you can only publish styles to the library. So yes, you need to upgrade to a paid plan.
For more information about publishing libraries and plans, see the following Help Center articles:
Ok thank you. And also I have another question: I only want to let the users to import the component and their changes only applies for themselves and not on the source component. Is it possible? or their changes will apply on the source component?
Modifications to imported components in user files will not affect your library.
Thank you
I’ve published a component and only my teammates can import it using its key. but I want everybody to access it. I have no idea what to do? I’m using an educational plan.
Not sure, but try changing the library file access to “Anyone with the link” with “can view” permission.