Livestream: Build better UIs with AI | 3/13

Announcing Visual Copilot - Figma to production in half the time

Builder logo
builder.io
Contact SalesGo to App
Builder logo
builder.io

Blog

Home

Resources

Blog

Forum

Github

Login

Signup

×

Visual CMS

Drag-and-drop visual editor and headless CMS for any tech stack

Theme Studio for Shopify

Build and optimize your Shopify-hosted storefront, no coding required

Resources

Blog

Get StartedLogin

‹ Back to blog

AI

Figma to Code - How to use your design system with AI

March 7, 2025

Written By Gustavo Garcia & Alexis Kulash

Design systems are awesome. They're the collection of reusable components, patterns, and guidelines that help teams build consistent products at scale. Tons of dev teams use them to maintain consistency and speed up development.

There's a common problem, however, designers create beautiful mockups in Figma, and then developers have to manually translate those designs into code.

The kicker? Most of the components in those mockups already exist in your design system. So why are we rebuilding them from scratch every time?

This is where Builder.io's Figma to Code plugin with component mapping comes in. I'll walk you through how it works and why it matters.

The problem with current Figma-to-code solutions

Most Figma-to-code solutions generate fresh code for everything they see. They don't know that the button in your mockup is the same Button component that's already in your codebase.

An illustration highlighting that without component mapping, most AI Figma to code solutions create separate code components for each design element.

This means you end up with:

  • Duplicate components
  • Inconsistent implementations
  • Code that doesn't follow your design system patterns
  • A lot of manual cleanup work
This visualization highlights the redundancy in UI development where designs created in Figma must be manually recreated in code, illustrating the frustration when design changes require additional development work.

Instead of generating new code, Builder.io's plugin can map Figma components to your existing design system components. It's like teaching the AI, "When you see this button in Figma, use our Button component from our codebase."

The illustration demonstrates an efficient design-to-code workflow where multiple Figma components map to a single reusable code component with the help of component mapping

This means when you export a design:

  • It recognizes your components
  • It uses code from your existing design system
  • You get output that matches your existing codebase and is ready to use with minimal editing

Let me walk you through a practical example of how this works.

An illustration showing the setup required to recreate the demo

For this demo, I'm using:

The magic happens in "mapper files" that tell Builder how to connect Figma components to your code components.

Here's the simple process:

  1. Select a component in Figma (like a button)
  2. Right-click and choose the Builder.io plugin
  3. Generate a mapper command
  4. Run that command in your project
  5. Select which component from your codebase to map it to
  6. Publish the mapper back to Figma

The CLI helps you through this process, even allowing you to provide documentation links so Builder better understands your component APIs. The more context our AI has, the better it can match your existing design and code.

Each mapper file contains:

  • A reference to the Figma component key
  • The properties available for that component
  • Default values for props
  • Logic for translating Figma properties to component props

For example, a button mapper might map the Figma "variant" property to your design system's "variant" prop.

While Builder's AI does a great job generating mapper files, you may want to make adjustments to fine-tune how Figma properties map to your components. Here's how to edit your mapper files:

  • Locate your mapper file: After generating a mapper, you'll find it in your project under a directory like builder/mappers.
  • Understand the structure: Each mapper file exports a function that defines how Figma properties translate to your component props. Look for sections like:
properties: {
  // This is where Figma properties are defined
},
defaultProps: {
  // Default values for your component
}
  • Edit property mappings: You can modify how Figma properties map to component props. For example, in the avatar mapper:
/ Map the alt text from Figma to your component
altText: {
  type: 'string',
  default: 'Avatar image'
}
  • Change default values: If your component needs specific default props, you can adjust them:
defaultProps: {
  variant: 'circular', // Default to circular avatars
  // Other default props
}
  • Test before publishing: Make your changes and test locally before publishing them back to Figma.
  • Publish your changes: Once you're happy with your edits, publish the updated mapper using:
npx @builder.io/figma publish

This process allows you to control exactly how Figma components map to your codebase, especially for more complex components or when you want to add special handling for certain properties.

Remember, you don't have to edit the mapper files manually - the AI-generated ones work well out of the box. But the option is there when you need more precise control.

Once you've created mappers for your components, the magic happens when you export new designs:

  1. In Figma, select a design element or frame
  2. Right-click and open the Builder.io plugin
  3. Under the "Design System" tab, you'll see which components are mapped
  4. Export to code
  5. The plugin generates code using your actual components

Instead of generic divs and spans, you get your Material UI Button, TextField, and other components with all the right props set.

If you notice a component that needs adjustments:

  1. Generate the mapper file using the plugin
  2. Edit the mapper file in your code editor to fine-tune the property mappings
  3. Publish your changes back to Figma

There are two main ways to use the output:

  1. In Builder.io: Paste the generated code into the Builder editor to create visual pages that use your design system
  2. In your codebase: Generate a React component that uses your design system and paste it directly into your project

This approach creates a tight feedback loop between design and development:

  • Designers work in Figma as usual
  • Developers map components once
  • New designs automatically use your design system
  • Everyone stays consistent with brand guidelines

It's especially powerful for teams with established design systems or those using component libraries like Material UI, where you want to leverage what you've already built.

This graphic illustrates how AI technology can automate the challenging middle steps of the development process, streamlining the journey from concept to launch.

If you want to try this yourself:

  1. Open the Builder.io Figma plugin
  2. Connect it to your Builder space
  3. Start mapping your most commonly used components
  4. Don't feel pressured to map everything at once—start with core elements like buttons, inputs, and cards

The more components you map, the more powerful the tool becomes, but even mapping just a few key components can save you tons of time.

Component mapping bridges the gap between design and development by connecting your Figma designs to your actual code components. Instead of rebuilding the wheel each time, you're leveraging what you've already built.

It's not just about saving time—it's about maintaining consistency across your applications and making it easier to adhere to your design system guidelines.

Keep in mind that component mapping is an enterprise feature in Builder.io. If you're ready to elevate your design-to-code workflow, you can start an enterprise trial to unlock this powerful capability.

If you're working with a design system (or thinking about creating one), this approach could dramatically streamline your workflow from design to production.

For a complete walkthrough of this process, check out our full Builder Labs webinar where we demonstrate the entire workflow from setup to implementation.

Share

Twitter
LinkedIn
Facebook
Hand written text that says "A drag and drop headless CMS?"

Introducing Visual Copilot:

A new AI model to turn Figma designs to high quality code using your components.

Try Visual CopilotGet a demo
Newsletter

Like our content?

Join Our Newsletter

Continue Reading
Web Design11 MIN
Creating Animated Accordions with the Details Element and Modern CSS
March 7, 2025
design to code5 MIN
Introducing our in depth Design-To-Code Guide
March 6, 2025
AI10 MIN
AI APIs in 2025
February 27, 2025