Design to code

Turn a frame into Flutter, SwiftUI, React + Tailwind or HTML + Tailwind code.

Pick a frame

Select a frame in Figma and ask your agent:

Prompt
implement the selected Figma frame

Or paste a Figma link that has a node-id. The id in the link (node-id=1-2) is the node 1:2. With no id, the tools use the current selection.

Prompt
implement https://www.figma.com/design/AbC123/App?node-id=42-1337

What the agent gets

get_design_context is the main tool. For a node it returns:

  • Reference code for your stack
  • The assets the code uses (SVGs and images), saved to disk
  • A screenshot of the node to compare against
  • The variables the node uses
The code is a reference, not the final answer. Your agent adapts it to your project: your theme, your widgets and your conventions.

Flutter, SwiftUI, React or HTML

The framework is chosen in this order:

  1. The framework argument, when the agent passes one (flutter, swiftui, react or html).
  2. The client's languages and frameworks (for example dart, swift or html).
  3. The FIGMA_LOCAL_MCP_FRAMEWORK environment variable.
  4. The working directory: a pubspec.yaml means Flutter, a Package.swift, .xcodeproj or .xcworkspace means SwiftUI, and an index.html without a package.json means a static HTML site. Anything else gets React + Tailwind.

Flutter

Start your agent in the Flutter project (the folder with pubspec.yaml) and Flutter is picked automatically. The code uses standard widgets, and SVGs are drawn with SvgPicture.asset, so add flutter_svg if the project doesn't have it:

Terminal
flutter pub add flutter_svg

Portrait frames of a phone's width (300–480) are drawn as a screen that fills the device and scrolls when it's tall. The agent can turn this on or off with screen.

Assets

SVGs and images go into the folders your pubspec.yaml declares under flutter: assets:. Folders named like assets/svg or assets/icons get the SVGs, and assets/images or assets/png get the images. Without them, both go to assets/figma. The agent can override this with assetsDir.

pubspec.yaml
flutter:
  assets:
    - assets/svg/
    - assets/images/
Prompt
implement the selected Figma frame as a Flutter screen

SwiftUI

Start your agent in a Swift package or an Xcode project (the folder with Package.swift, an .xcodeproj or an .xcworkspace) and SwiftUI is picked automatically. The view is written the way a production screen is built, not as a stack of fixed boxes.

  • Real controls. Buttons with a press style, selection with a sliding indicator and haptics, Toggles, ProgressViews, calendars, snapping carousels, LazyVGrid grids, and pinned bars in safeAreaInset.
  • Exact values. Sizes are in points, fonts are named by PostScript face and scale with Dynamic Type, and text keeps Figma's line boxes. Rows and grids stack at accessibility sizes.
  • Design tokens. The design's variables become DesignTokens in a shared DesignSystem.swift, with Color(hex:) and the button style. Merge it into the target once; later screens add only what it lacks.
  • Ready to wire up. Selection is @State set to the design, and the screen asks its owner to act through a nested Action enum, so moving state to a view model and adding navigation is straightforward.
  • A Structure block. The response names what each part is, how sure the detection is and why, and the SwiftUI pattern the code uses. A layer name tag such as Pay [button] or [no-role] sets or clears a role.

Assets

Images go into the project's asset catalog as image sets: the app's own *.xcassets, else Assets.xcassets. The agent can name another catalog with assetsDir. In a Swift package, put the catalog under the target's resources and load images with Image("name", bundle: .module).

Prompt
implement the selected Figma frame as a SwiftUI view

React + Tailwind

Every other project gets a React component with Tailwind classes: Next.js, Vite, Remix or plain React. Auto layout frames become flex boxes, grids become CSS grids, and everything else is placed by its constraints. The classes work in Tailwind 3.4 and 4.

  • Exact values. Sizes, spacing, radii, colours, fonts and line heights match the design. Theme classes like px-4 or rounded-full are used only where they equal the design value; everything else uses arbitrary values like text-[#0a1f44].
  • Real fonts. Classes name the font family itself, and the response lists the families and weights to load.
  • Design tokens. Variables appear as var(--name,value), and the response includes the CSS that declares them, with a Tailwind 4 @theme that turns them into utilities.
  • Readable code. Repeated items (cards, list rows, tabs) become a data array with .map(), and Figma text styles used more than once are named in a textStyles object.
  • Semantic markup. Prototype taps and layer names give buttons, links, navigation, headers and footers; heading text styles give h1–h6; placeholders give text inputs; content images get alt text.
  • Screens and pages. Phone frames fill the screen and scroll; rows wider than the screen scroll sideways. Frames 768 wide or more are web pages: full-width sections stretch across the screen and the rest stays in a centred column. The agent can turn these off with screen and page.
  • Assets in your project. SVGs and images are named after their layers, with the commands to copy them into public/figma (static/figma for SvelteKit).
Prompt
implement the selected Figma frame as a React component with Tailwind

HTML + Tailwind

Static sites get the same markup as plain HTML with Tailwind classes, ready to paste into a page that builds its CSS with the Tailwind CLI. Assets go to assets/figma beside the page.

Prompt
implement the selected Figma frame as an HTML page with Tailwind

Check the result

verify_code renders the code in headless Chrome and compares it with Figma's own render of the frame: layout mismatches, differing pixels and a diff image. It checks the generated code, a component or page from your project with its stylesheet, or a layout on a phone-sized screen. It needs Chrome, and loads React and Tailwind from a CDN.

Flutter code is analyzed and rendered with flutter test. SwiftUI code is compiled and rendered in the iOS simulator (Xcode needed), and the check can tap every button and render at other Dynamic Type sizes.

Prompt
check my component against the Figma frame with verify_code

What the check does not cover

A pixel match says the default state looks right. It does not say the button's pressed or disabled state, its keyboard behaviour or its screen-reader name are right. So every verify_code result has a coverage block:

  • Checked: what the run did, such as the default state at the design size, the layer boxes, the buttons it tapped or the keys it pressed.
  • Not checked, per control: each button, field, toggle or tab row with the states, keyboard and screen-reader behaviour no check covered. A state the design draws (a State=Disabled variant) is told apart from one it never drew, so the designer knows what to add.
  • Screen: dark mode, other widths and text sizes, right-to-left and reduced motion.

React and HTML checks also press Tab through the page and report the Tab order, controls with no visible focus indicator, buttons Enter or Space does not activate, controls without an accessible name and clickable elements the keyboard cannot reach. A control the design has but the code draws as a plain element is called out, since keyboard and screen-reader users cannot use it. The agent hands the not-checked list back with its implementation, so the next reviewer knows what is left.

verify_code (part of the result)
"coverage": {
  "checked": ["default state at 393x852, light mode: 0.8% of pixels differ", "keyboard: 4 elements reached with Tab, ..."],
  "notChecked": [{
    "element": "Pay now (button, 1:2)",
    "checked": ["reached with Tab (stop 4)", "Enter/Space activates it", "accessible name "Pay now""],
    "notChecked": ["disabled state (in the design as State=Disabled; not rendered)", "loading state (not in the design)", "no visible focus indicator"]
  }],
  "screen": ["dark mode", "widths other than 393", "browser zoom and larger text", "right-to-left languages"]
}

Large frames

Very large nodes return metadata (the layer outline) instead of code, so the agent can read the sections one by one. Ask for a child frame, or have the agent pass forceCode to get code for the whole node.

Tips

  • Use auto layout in Figma where you can. It maps directly to rows, columns and flex.
  • Name your layers. Names show up in the code and help the agent pick widget names.
  • Map shared components with Code Connect so instances become your own components.
  • Ask the agent to compare its result with get_screenshot when the details matter.