Retour au classement

bernaferrari/FigmaToCode

TypeScriptfigma.com/community/plugin/842128343887142055

Generate responsive pages and apps on HTML, Tailwind, Flutter and SwiftUI.

figmafigma-pluginstypescriptsveltetailwindcssflutterresponsiveswiftswiftuihtmltailwindconversion
Croissance des étoiles
Étoiles
5.1k
Forks
485
Croissance hebdomadaire
Issues
41
2k4k
juil. 2020juil. 2022juil. 2024juil. 2026
Artefactsnpmnpm install figmatocode
README

Figma to Code

Figma to Code

Twitter

Converting Figma designs into usable code can be a challenge, often requiring time-consuming manual work. Figma to Code simplifies that process. This plugin generates responsive layouts in HTML, React (JSX), Svelte, styled-components, Tailwind, Flutter, and SwiftUI directly from your designs. Your feedback and ideas are always welcome.

Gif showing the conversion

How it works

The plugin uses a sophisticated multi-step process to transform your Figma designs into clean, optimized code:

  1. Node Conversion: First, the plugin converts Figma's native nodes into JSON representations, preserving all necessary properties while adding optimizations and parent references.

  2. Intermediate Representation: The JSON nodes are then transformed into AltNodes - a custom virtual representation that can be manipulated without affecting your original design.

  3. Layout Optimization: The plugin analyzes and optimizes layouts, detecting patterns like auto-layouts, responsive constraints and color variables.

  4. Code Generation: Finally, the optimized structure is transformed into the target framework's code, with special handling for each framework's unique patterns and best practices. If a feature is unsupported, the plugin will provide a warning.

Conversion Workflow

This intermediate representation approach allows for sophisticated transformations and optimizations before any code is generated, resulting in cleaner, more maintainable output.

Hard cases

Converting visual designs to code inevitably encounters complex edge cases. Here are some challenges the plugin handles:

  1. Complex Layouts: When working with mixed positioning (absolute + auto-layout), the plugin has to make intelligent decisions about how to structure the resulting code. It detects parent-child relationships and z-index ordering to produce the most accurate representation.

  2. Color Variables: The plugin detects and processes color variables, allowing for theme-consistent output.

  3. Gradients and Effects: Different frameworks handle gradients and effects in unique ways, requiring specialized conversion logic.

Conversion Workflow

Tip: Instead of selecting the whole page, you can also select individual items. This can be useful for both debugging and componentization. For example: you can use the plugin to generate the code of a single element and then replicate it using a for-loop.

Todo

  • Vectors (possible to enable in HTML and Tailwind)
  • Images (possible to enable to inline them in HTML and Tailwind)
  • Line/Star/Polygon

How to build the project

Package Manager

The project is configured for pnpm. To install, see the installation notes for pnpm.

Monorepo

The plugin is organized as a monorepo. There are several packages:

  • packages/backend - Contains the business logic that reads the Figma API and converts nodes

  • packages/plugin-ui - Contains the common UI for the plugin

  • packages/eslint-config-custom - Config file for ESLint

  • packages/tsconfig - Collection of TSConfig files used throughout the project

  • apps/plugin - This is the actual plugin assembled from the parts in backend & plugin-ui. Within this folder it's divided between:

    • plugin-src - loads from backend and compiles to code.js
    • ui-src - loads the common plugin-ui and compiles to index.html
  • apps/debug - This is a debug mode plugin that is a more convenient way to see all the UI elements.

Development Workflow

The project uses Turborepo for managing the monorepo, and each package is compiled using esbuild for fast development cycles. Only modified files are recompiled when changes are made, making the development process more efficient.

Running the Project

You have two main options for development:

  1. Root development mode (includes debug UI):

    pnpm dev
    

    This runs the plugin in dev mode and also starts a Next.js server for the debug UI. You can access the debug UI at http://localhost:3000.

  2. Plugin-only development mode:

    cd apps/plugin
    pnpm dev
    

    This focuses only on the plugin without the Next.js debug UI. Use this when you're making changes specifically to the plugin.

Where to Make Changes

Most of your development work will happen in these directories:

  • packages/backend - For plugin backend
  • packages/plugin-ui - For plugin UI
  • apps/plugin/ - The main plugin result that combines the backend and UI and is called by Figma.

You'll rarely need to modify files directly in the apps/ directory, as they mostly contain build configuration.

Commands

pnpm run ...

  • dev - runs the app in dev mode. This can be run in the Figma editor.
  • build - builds the project for production
  • build:watch - builds and watches for changes
  • lint - runs ESLint
  • format - formats with prettier (warning: may edit files!)

Debug mode

When running the dev task, you can open http://localhost:3000 to see the debug version of the UI.

Screenshot 2024-12-13 at 16 26 43

Issues

The Figma file for this README and icon is also open and welcome to changes! Check it here.

I took decisions thinking about how it would benefit the majority of people, but I can (and probably will!) be wrong many times. Found a bug? Have an idea for an improvement? Feel free to add an issue or email me. Pull requests are also more than welcome.

Dépôts similaires
VoltAgent/awesome-design-md

A collection of DESIGN.md files analysis by popular brand design systems. Drop one into your project and let coding agents generate a matching UI.

MIT Licenseawesome-listdesign-md
getdesign.md
103.7k11.9k
onlook-dev/onlook

The Cursor for Designers • An Open-Source AI-First Design tool • Visually build, style, and edit your React App with AI

TypeScriptnpmApache License 2.0reacttypescript
onlook.com
26.2k2k
lucide-icons/lucide

Beautiful & consistent icon toolkit made by the community. Open-source project and a fork of Feather Icons.

TypeScriptnpmOthersvgsicons
lucide.dev
23.6k1.5k
GLips/Figma-Context-MCP

MCP server to provide Figma layout information to AI coding agents like Cursor

TypeScriptnpmMIT Licenseaicursor
framelink.ai
15.5k1.2k
BuilderIO/mitosis

Write components once, run everywhere. Compiles to React, Vue, Qwik, Solid, Angular, Svelte, and more.

TypeScriptnpmMIT Licensejsxreact
mitosis.builder.io
13.9k634
ParthJadhav/Tkinter-Designer

An easy and fast way to create a Python GUI 🐍

PythonPyPIBSD 3-Clause "New" or "Revised" Licensetkintertkinter-gui
10.3k934
astrit/css.gg

700+ Pure CSS, SVG & Figma UI Icons, 6000+ glyphs, patterns, colors and layouts.

JavaScriptnpmOthercssicons
css.gg
10k496
themesberg/flowbite

Open-source UI component library and front-end development framework based on Tailwind CSS

HTMLMIT Licensecsshtml
flowbite.com
9.3k872
dicebear/dicebear

DiceBear is an avatar library for designers and developers. 🌍

VueMIT Licenseavatarpixel-art
dicebear.com
9.1k397
grab/cursor-talk-to-figma-mcp

TalkToFigma: MCP integration between AI Agent (Cursor, Claude Code, Codex) and Figma, allowing Agentic AI to communicate with Figma for reading designs and modifying them programmatically.

JavaScriptnpmMIT Licenseagentagentic
figma.com/community/plugin/1485687494525374295/cursor-talk-to-figma-mcp-plugin
6.9k750
iconoir-icons/iconoir

An open source icons library with 1600+ icons, supporting React, React Native, Flutter, Vue, Figma, and Framer.

TypeScriptnpmMIT Licenseiconssvg
iconoir.com
4.5k197
BuilderIO/micro-agent

An AI agent that writes (actually useful) code for you

TypeScriptnpmMIT Licenseagentai
builder.io/blog/micro-agent
4.3k380