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:
implement the selected Figma frameOr 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.
implement https://www.figma.com/design/AbC123/App?node-id=42-1337What 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
Flutter, SwiftUI, React or HTML
The framework is chosen in this order:
- The
frameworkargument, when the agent passes one (flutter,swiftui,reactorhtml). - The client's languages and frameworks (for example
dart,swiftorhtml). - The
FIGMA_LOCAL_MCP_FRAMEWORKenvironment variable. - The working directory: a
pubspec.yamlmeans Flutter, aPackage.swift,.xcodeprojor.xcworkspacemeans SwiftUI, and anindex.htmlwithout apackage.jsonmeans 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:
flutter pub add flutter_svgPortrait 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.
flutter:
assets:
- assets/svg/
- assets/images/implement the selected Figma frame as a Flutter screenSwiftUI
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,
LazyVGridgrids, and pinned bars insafeAreaInset. - 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
DesignTokensin a sharedDesignSystem.swift, withColor(hex:)and the button style. Merge it into the target once; later screens add only what it lacks. - Ready to wire up. Selection is
@Stateset to the design, and the screen asks its owner to act through a nestedActionenum, 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).
implement the selected Figma frame as a SwiftUI viewReact + 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-4orrounded-fullare used only where they equal the design value; everything else uses arbitrary values liketext-[#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@themethat 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 atextStylesobject. - 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
screenandpage. - Assets in your project. SVGs and images are named after their layers, with the commands to copy them into
public/figma(static/figmafor SvelteKit).
implement the selected Figma frame as a React component with TailwindHTML + 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.
implement the selected Figma frame as an HTML page with TailwindCheck 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.
check my component against the Figma frame with verify_codeWhat 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=Disabledvariant) 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.
"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_screenshotwhen the details matter.