Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Contact Us
  • Home
  • Community – Figma Learn
  • Creator tools and resources
  • Plugins & Widgets

Widget Code Generator by Figma

Written by Figma Man

Updated at June 19th, 2025

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Administration – Figma Learn
    Manage files and projects Manage a team Manage your account Manage a Figma organization Manage Enterprise plan settings and permissions Billing Manage Figma in a school
  • Figma Design – Figma Learn
    Create prototypes Import and export Create designs Tour the interface Dev Mode Work together in files Build design systems Figma Draw
  • Get started – Figma Learn
    Set up your account Layers 101
  • FigJam – Figma Learn
    Import and export Run meetings Work on boards Tour the interface
  • Community – Figma Learn
    Explore the Community Creator tools and resources
  • Help – Figma Learn
    Troubleshoot Common questions Work with support
  • Work across Figma – Figma Learn
    Figma AI Work across Figma
  • Courses, tutorials, projects – Figma Learn
    Courses Projects
  • Figma Slides – Figma Learn
    Create and edit slides Present slide decks Tour the interface Import and export
  • Figma Buzz – Figma Learn
    Templates in Figma Buzz Create and edit assets in Figma Buzz Overview
  • Figma Make – Figma Learn
    Tour the interface Work with Figma Make
  • Figma Sites – Figma Learn
    Design a site Create webpages and breakpoints Make your site interactive Preview and publish a site Tour the interface
+ More

Table of Contents

Run the plugin Generate code Instance nodes Create inputs Render images What’s not supported
🚧  Widget Code Generator is currently in open beta

Beta features can change during the beta period. You may experience bugs or performance issues during this time. Learn more about beta features →

Before you start

Who can use this feature

Supported on any team or plan.

This plugin is for Figma Design only. You must use the Figma Desktop app to develop widgets.

Download the Figma Desktop app ->

The Widget Code Generator plugin for Figma Design allows you to design FigJam widgets and easily translate your designs into code. This Figma plugin generates code that you can copy and use to create a widget interface. In order to add functionality to your widget, you’ll need to edit the generated code. Learn how to build widgets →

In order to use generated code from the plugin, you need to:

  • Setup your widget development environment. Check out the setup guide here →
  • Install the Widget Code Generator from the Figma Community. Learn how to find and install plugins →

Run the plugin

Once you have Widget Code Generator installed, you can run it a few different ways:

  • Right-click on the canvas > Plugins > Select Widget Code Generator
  • From the desktop app, open the Plugins menu at the top then select Widget Code Generator

After selecting the plugin, the Widget Code Generator modal will pop up.

WCG_Modal.png

Generate code

The Widget Code Generator can only generate code one layer at a time, including all of the children in the layer tree. Select an individual layer while the plugin is running to see the generated code in the modal.

wcg-codegen-1.gif

If changes are being made to a layer, the generated code won’t automatically update. After making changes to a layer, hit the ‘Refresh’ button to get the most updated code for your component.

codegen-refresh.gif

Note

When preparing to generate code for your design, make sure that you are only using characters A-Z and 0-9 in your layer names and that none of your components have reserved names that are used for Figma component types(ie. frame, rectangle).

Instance nodes

When you generate code for a design containing an Instance node, the code for all layers of that instance will not be included. Instead, a tag representing the instance will be shown. This reduces duplication when you use several instances of the same component, and makes your generated code more readable. If your design includes several instances of a component named MyComponent, the generated code will look like this:

export function MyDesign() {
  return <Frame>
  	<MyComponent/>
	<MyComponent/>
	<MyComponent/>
 </Frame>
}

If you copy-paste this into your editor and try to run it, it will not compile because MyComponent will be undefined.

To fix this, select MyComponent in Figma and generate code for that instance. To go to the main component, right-click on the individual layer then select Go to main component. You can also click on the Go to main component link that appears in the warning message at the top of the modal. 

Instance_Nodes.png

Create inputs

Since there’s no way to mark a component as an Input in Figma, the Design→Code plugin can’t generate <Input/> tags.

If your widget design contains an input:

  1. Design the input field using the Text layer type.
  2. Generate code for the text layer using the plugin.
  3. Locate the opening and closing Text tags for that node and replace them with Input.
  4. Add props for onTextEditEnd, placeholder and value to make your input functional.

Render images

To render an image in a widget, the image must be externally hosted or passed in as a data URI. Since we don’t know where your image will come from, we can’t generate complete code for an Image tag. Instead, you will receive something like:

<Image src="<Add image URL here>"/>

Complete the code with the correct image source and it will be visible in your widget!

What’s not supported

The following features are supported in Figma Design, but aren’t supported in Widgets yet and therefore cannot be generated:

  • Masks
  • Fonts from your computer you’ve uploaded to Figma (not Google fonts)
  • Multiple text styles in one node (plugin will generate the first style)
  • Layer names with characters outside of A-Z and 0-9
  • Nodes with a width or height of less than 1px will be rounded up to 1px
  • Gradient strokes (supported in widgets but the plugin currently doesn’t generate code for it)

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Security disclosure principles
  • Make plugins for the Figma Community
  • Plugin and widget review guidelines
  • Publish plugins to the Figma Community
  • Manage plugins as a developer
  • Blog
  • Best practices
  • QR code generator
  • Color wheel
  • Colors
  • Color picker
  • Color palettes
  • Color palette generator
  • Color contrast checker
  • Font Library
  • Templates
  • Developers
  • Integrations
  • Affiliate program
  • Resource library
  • Reports and insights
  • Support
  • Status
  • Legal and privacy
  • Modern slavery statement
  • Climate disclosure statement
  • COMPARE
  • Sketch
  • Adobe XD
  • Framer
  • Miro
  • COMPANY
  • Events
  • Customers
  • Careers
  • Newsroom
Expand