Create scalable Figma plugins with ease, using the power of Svelte + Vite!
This is a boilerplate for building Figma plugins with Svelte, Vite, and TypeScript. To learn more about building plugins, see the Figma Plugin API documentation
Based on the great work of figma-plugin-react-vite
-
Tabular: Use as many tabs as needed to create a multi-tabbed UI. Create a new entry in
src/ui/furniture/tabs/
with an associatedname
andicon
in the module context. It will be automatically added to the UI's nav bar. -
Common Code: Figma plugins with an interface are rendered using Figma-side code (code.ts on Figma docs) and sandboxed UI code (index.html on Figma docs). This template keeps the two sides separate (
src/ui
andsrc/plugin
) but keeps common code available viasrc/common
. -
Communicative: Plugin and UI code can communicate via postMessaging. This boilerplate has a built-in postMessage handler to send messages between the plugin and UI. (See /src/ui/lib/components/Message.svelte for code source and examples)
-
Iterative: Configure your figma.manifest.ts credentials just once. Run
npm run build
and your plugin is ready to publish via your/dist
folder! -
One File: Figma UI plugins accept only a single file each for Figma-side code (js) and UI-side code (html), which makes deployment of multiple files linked to each other impossible. This template is configured with vite-single-file to bundle or inline files, imports, vectors and more.
-
Figma's Icons: This boilerplate is configured with Figma's icon library for consistency and ease of use. Just use the
<FigmaIcon />
component to render an SVG icon from the library. (See /src/ui/lib/components/figma-icons/FigmaIcon.svelte for code source and examples) -
Tailwind-ready: This boilerplate is configured with tailwindcss and postcss for out-of-the-box utilities and styling.
- src
- src/common/ : Sources that are intended to be used both by plugin and ui logical sides.
- src/plugin/ : Sources of the plugin logical side. Place everything that interracts with Figma here.
- src/ui/ : Sources of the ui logical side, a classical Vite + Svelte source base.
- scripts
- scripts/vite/ : Some custom vite plugins to assist inlining assets
- figma.manifest.ts - A module that exports Figma Plugin Manifest for the build scripts
- Clone this repository
- Install dependencies with
npm install
- In Figma, go to
Plugins
>Development
>New Plugin...
and follow the prompts - Copy the contents of
manifest.json
into thefigma.manifest.ts
file in this repository's root folder - Run
npm run dev
to build the plugin. This command will watch for changes and rebuild the plugin automatically, updating Figma's plugin instance with the changes. - To publish the plugin, run
npm run build
and upload the/dist
folder to the Figma Developer Console
- Images must be either inlined SVGs or be small enough to be inlined as data URIs. Figma plugins are sandboxed and cannot load external resources, so assets must be inlined.
- This boilerplate uses Svelte for the UI, Vite for the build system, and TypeScript for type checking.
- The plugin is built to the
/dist
folder, which is ignored by Git. This folder is what you upload to the Figma Developer Console when publishing your plugin.