/    Sign up×
Articles /Pin to ProfileBookmark

How to create widgets in Figma using the Widget API

Figma is a powerful design tool that allows designers to create interfaces, wireframes, and prototypes with ease. One of the many features that make Figma stand out is its extensibility. With Figma’s Widget API, designers can create custom widgets to enhance their designs.

Widgets are interactive elements that can be added to Figma designs. They can be used to create interactive prototypes or to add functionality to a design. Figma’s Widget API allows designers to create custom widgets using HTML, CSS, and JavaScript.

In this article, we will walk through the process of creating a simple widget using Figma’s Widget API. We will start by setting up our development environment and then move on to creating the widget. You should be familiar with and Node.js and using CLI for this tutorial.

Setting up the Development Environment

To get started, we will need to set up our development environment. We will need to have Node.js installed on our computer. If you don’t have Node.js installed, you can download it from the official website.

Once you have Node.js installed, open your terminal and run the following command to install the Figma CLI:

npm install --global figma-cli

Next, we need to create a new Figma plugin project. Run the following command in your terminal:

figma create-plugin

This will create a new Figma plugin project with the necessary files and folders.

Creating the Widget

Now that our development environment is set up, we can start creating our widget. The first step is to create a new HTML file in the project’s src folder. Let’s call it widget.html. This file will contain the HTML, CSS, and JavaScript code for our widget.

Next, we need to create a new file called widget.json in the project’s src folder. This file will contain the metadata for our widget, including its name, description, and icon.

Here is an example of what the widget.json file might look like:

 "name": "My Widget",
 "description": "A custom widget created using Figma's Widget API",
 "icon": "icon.svg"

The icon field should point to a SVG file that will be used as the icon for the widget in the Figma editor.

Now that we have created the necessary files, we can start writing the HTML, CSS, and JavaScript code for our widget.

The HTML for our widget can be as simple or as complex as we want. For this example, let’s create a simple button that will display an alert when clicked:

<button id="my-button">Click me!</button>

Next, let’s add some CSS to style our button:

#my-button {
 padding: 10px 20px;
 background-color: #3f51b5;
 color: #fff;
 border: none;
 border-radius: 4px;
 cursor: pointer;

Finally, let’s add some JavaScript to make our button display an alert when clicked:

document.getElementById('my-button').addEventListener('click', function() {
 alert('Button clicked!');

Once we have written our HTML, CSS, and JavaScript code, we need to bundle it into a single file that Figma can use. To do this, run the following command in your terminal:

figma package

  This will create a single widget.bundle.js file in the project’s dist folder. This file contains all the code for our widget.  

Testing the Widget

Now that we have created our widget, we can test it in the Figma editor. To do this, we need to run the following command in our terminal:

figma serve

This will start a local server that will serve our widget to the Figma editor. Once the server is running, open Figma and create a new design file. In the Figma editor, click on “Plugins” in the sidebar, then click on “Development” and select our widget from the list.

If everything is working correctly, our widget should appear in the Figma editor. Click on the button to make sure it displays the alert.

Publishing the Widget

Once we are happy with our widget and it is working correctly, we can publish it to the Figma community. To do this, we need to first create a new release of our plugin:

figma release

This will create a new version of our plugin that can be published to the Figma community. To publish our widget, we need to go to the Figma developer dashboard and click on “Publish New Plugin”. Fill in the necessary information, including the name and description of the widget, and upload the widget.bundle.js file.

Once the widget is published, it will be available to other Figma users in the community. They can install the widget and use it in their own designs.


Creating custom widgets using Figma’s Widget API is a powerful way to add functionality to your designs. With just a little bit of HTML, CSS, and JavaScript, you can create custom widgets that can be used by other Figma users in the community. By following the steps outlined in this article, you should be able to create your own custom widgets and start enhancing your Figma designs. If you like to create Widgets manually, you find an article covering this topic here. I hope this helps you getting started with Figma’s Widget API. Happy designing and sharing your designs with the community.

FigmaFront-endNode.jsUX Engineer


Help @steime spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 9.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ

legal: ({
terms: of use,
privacy: policy
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
recent_tips: (
tipper: @ddiebold17,
tipped: article
amount: 1000 SATS,

tipper: @Mqlinka19,
tipped: live stream
amount: 4900 SATS,

tipper: @Mqlinka19,
tipped: article
amount: 10 SATS,