Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

React
  • One Request, Two Answers: the Same Post as an HTML Page and as JSON
  • A Blog Design from a Prompt: Downloading Figma Make Code and Reading App.tsx and BlogCard.tsx
  • How a Web Page Works: HTML Tags, Elements and Attributes
  • Semantic HTML: header, nav, main, aside and footer as Page Landmarks
  • HTML Forms: Labels, Names, Input Types and Where the Data Goes (GET vs POST)
  • CSS Basics: Selectors, Which Rule Wins, and the Box Model
  • CSS Flexbox vs Grid: A Nav Bar, a Card Row and a Dashboard
  • Responsive CSS: Viewport, Mobile-First Media Queries, clamp() and Dark Mode with Tokens
  • JavaScript for People Who Already Code: Syntax, Modules and Five Surprises
  • JavaScript Arrays the Functional Way: map, filter, reduce, find, sort and Object.entries
  • Async JavaScript: Promises, async/await, fetch and Promise.all
  • JavaScript in the Page: the DOM, querySelector and Events
  • npm, package.json and Vite: What npm install Fetches and How Vite Serves and Builds Your Page
  • TypeScript Essentials: Types Checked, Then Erased (Interfaces, Unions, Generics)
  • Why React, JSX and Components: The Page as a Function of Data
  • React Props and Composition: Data Down, Calls Up, Children in the Slot
  • Routing With React Router: One Page, Many Addresses
  • React Component Tests With Vitest and Testing Library: Test What the User Sees
  • End-to-End Tests for a React App With Playwright: A Full Dress Rehearsal
  • Why AI-Built Websites All Look the Same, and Four Levels That Fix It
  • Visual Hierarchy, Spacing and the 8-Point Grid: Tell the Eye What to Read First
  • Colour, Contrast and Dark Palettes: 60-30-10, Semantic Tokens and Ratios You Can Compute
  • Typography That Sells: Type Scale, Line Length and Free Font Pairings
  • The UI Element Catalogue: Buttons to Toasts, Their Jobs, States and shadcn/ui Names
  • Design Tokens: Primitive and Semantic Tokens, from Figma to CSS to Tailwind
  • Tailwind CSS 4 in React: Utility Classes, Responsive Prefixes, Hover and Dark Mode
  • shadcn/ui in React: Components You Own, Edit and Commit
  • Design Tokens to a Tailwind Theme: Light and Dark Mode with @theme inline
  • Motion in React: Entrance, Hover, Exit and Layout Animations
  • A React Dashboard: Stat Cards, a Recharts Line Chart and a Sortable Table
  • Accessibility in Practice: Dialogs, Menus and the Keyboard in React
  • Reference-Driven Design: Extract a DESIGN.md From a Site You Admire and Build From It
  • Components, Variants and Variables: One Design System in Figma and in CSS
  • Figma MCP Server: Build a React Component From a Frame, Then Write It Back
  • Claude Design: From a Brief to a Clickable Prototype, Then Hand It Off to Claude Code
  • Critiquing AI-Generated UI: Six Checks for Every Screen
  • The AI Design Landscape: Prompt to UI, Prompt to App, and Design to Code
  • Your Brand Rules Folder: One Folder Every AI-Built Page Follows
  • The Best-Practice UI Prompt: Plain Sentences That Beat the Average AI Page
  • UI Ideas From Figma Make, Google Stitch and ChatGPT: One Prompt, Three Designs
  • Google Stitch From a Sketch or Screenshot: Show the Layout, Say What to Keep
  • Stitch to Figma to Code: Turn a Stitch Screen Into Code That Uses Your Tokens
  • Figma Make: Prompt to Prototype With a Four-Part Prompt
  • Upgrade a Dated UI From One Screenshot (or a Reference Image)
  • States and Feedback: Make Every Click Get an Answer
  • A Design-Loop Skill: Claude Screenshots, Scores and Fixes Its Own UI
  • Copy Without the AI Tells: A Copy Pass on a Landing Page
  • React State, Events, Lists and Conditional Rendering: Follow One Click
  • React useEffect: When It Runs, What Cleanup Is For, and When You Don't Need One
  • Lifting State Up, Refs and React DevTools: Put State Where It Is Needed
  • Forms and Actions in React 19: Controlled Inputs, Form Actions, useActionState and useFormStatus
  • React Context and Custom Hooks: Share One Value, Reuse the Logic
  • Server State With TanStack Query: One Key, One Request, One Cache
  • Mutations and Optimistic Updates in TanStack Query: Change Data, Then Tell the Cache
  • Generate TypeScript Types, Query Hooks and Zod From an OpenAPI Spec With Orval
  • A Mock Backend in the Browser With Mock Service Worker, Generated From the Spec
  • A React Client for a FastAPI API: The CORS Wall, CORSMiddleware and the Vite Proxy
  • Forms With React Hook Form and Zod: The API's Rules in the Browser, the Server's Errors Under the Field
  • JWT Auth in a React Client With a FastAPI Backend: Log In, Carry the Token, Let the Server Decide
  1. Blog
  2. /
  3. React
  4. /
  5. Fundamentals

Figma MCP Server: Build a React Component From a Frame, Then Write It Back

The Figma MCP server lets a coding agent read real frames, variables and Code Connect mappings instead of guessing from a screenshot. Build a TaskCard component from named tokens, render it with Vite, then write it back into Figma as a new frame.

Chaand Sheikh

·27 November 2026·Updated 28 November 2026Fundamentals

What you will learn

  • Connect the remote Figma MCP server to VS Code or Claude Code
  • Name the three read tools the agent calls to turn a frame into a component
  • Map Figma variables to Tailwind CSS 4 tokens so no hex colour lands in a component
  • Write a component back into Figma as a new frame bound to the same variables

Before you start

  • What Is MCP? Host, Client and Server
  • Basic React components and props

Give a cook a blurry photo of a recipe and they squint and guess the amounts. Put the recipe book open on the counter and they read the exact numbers. Pasting a screenshot of a design into an AI tool is the photo: the colours and the spacing get guessed. The Figma MCP server is the open book. The agent reads your frames, your variables and your component mappings straight from the file.

In this lesson the agent works in both directions in one session. It reads a Figma frame and builds a React component from it, and then it writes a component from code back into Figma as a new frame. The project is a small React 19, Vite and Tailwind CSS 4 app. We type in VS Code, but any editor works.

If MCP is new to you, read What Is MCP? Host, Client and Server first.

Figma MCP: design to code, and back Figma file frames variables Your repo TaskCard.tsx index.css tokens 1. design to code get_design_context, get_variable_defs use_figma, generate_figma_design 2. code to design Code Connect frame and file point to each other
One loop, two directions. The read tools turn a frame into a component; the write tools turn a component into a frame. Code Connect keeps the two linked.

Connect the server once

This is an example setup. Figma changes these steps from time to time, so check Figma's developer docs for the current version before you start. You also need a Figma account with a Dev or Full seat.

In VS Code the server is one entry in .vscode/mcp.json. The url points at Figma's hosted server and the type is http. That's the whole entry.

{
  "inputs": [],
  "servers": {
    "figma": {
      "url": "https://mcp.figma.com/mcp",
      "type": "http"
    }
  }
}

In Claude Code one command does the same job:

claude mcp add --transport http figma https://mcp.figma.com/mcp

Then start a new session, run /mcp, choose figma and authenticate. You sign in to Figma once, in the browser. For more on scopes and on fixing a server that won't connect, see Configuring MCP Servers in Claude Code.

Design to code: the agent reads

The Figma file has a TaskCard frame, a few variables (surface, brand, text-secondary, radius-card) and a Button component. Select the frame in Figma, copy its link, and ask the agent:

Using the Figma MCP server, read the TaskCard frame I selected (design context,
variables and the Code Connect mapping). Build it as a React 19 + Tailwind CSS 4
component called TaskCard with props title, owner, due and done. Use the named
variables as Tailwind theme tokens, not hex colours, and reuse my existing
Button component.

The agent makes three read calls. The values below come from the lecture's simplified mock-up, so treat them as examples:

ToolWhat it returnsExample
get_design_contextThe structure of the frameTaskCard, 320 x 190, auto layout, padding 20, radius 16
get_variable_defsThe variables the frame uses, with valuessurface #FFFFFF, brand #4F46E5, text-secondary #64748B
get_code_connect_mapWhich Figma components already exist in your codeButton maps to src/Button.tsx

The third call matters more than it looks. Code Connect tells the agent that the "View task" button already lives in src/Button.tsx, so it reuses that file instead of inventing a second button.

Variables become tokens

Each Figma variable turns into a CSS token, and Tailwind turns the token into a class:

Figma variableCSS tokenTailwind class
surface--color-surfacebg-surface
brand--color-brandbg-brand
text-secondary--color-text-secondarytext-text-secondary
radius-card--radius-cardrounded-card

Yes, text-text-secondary looks funny. It's correct: text- is the Tailwind prefix and text-secondary is the token name. The tokens live in one @theme block in src/index.css:

@import "tailwindcss";

/* Variables that were read from the Figma file (get_variable_defs) */
@theme {
  --color-surface: #ffffff;
  --color-surface-muted: #f1f5f9;
  --color-text-primary: #0f172a;
  --color-text-secondary: #64748b;
  --color-brand: #4f46e5;
  --color-brand-soft: #e0e7ff;
  --color-success: #059669;
  --radius-card: 16px;
  --spacing-card: 20px;
}

body { margin: 0; font-family: system-ui, sans-serif; background: var(--color-surface-muted); }

The point is that no hex colour ends up inside the component. When the designer changes a variable, every card changes with it. Names, not numbers. The idea of tokens is covered in more depth in Components, Variants and Variables.

TaskCard.tsx: built from names

This is the component a session like that produces:

import { Button } from './Button'

type Props = {
  title: string
  owner: string
  due: string
  done?: boolean
}

export function TaskCard({ title, owner, due, done }: Props) {
  return (
    <article className="w-80 rounded-card bg-surface p-card shadow-md">
      <div className="flex items-center justify-between">
        <h3 className="text-lg font-bold text-text-primary">{title}</h3>
        <span
          className={`rounded-full px-3 py-1 text-xs font-semibold ${
            done ? 'bg-success text-white' : 'bg-brand-soft text-brand'
          }`}
        >
          {done ? 'Done' : 'Open'}
        </span>
      </div>
      <p className="mt-2 text-sm text-text-secondary">Owner: {owner}</p>
      <p className="text-sm text-text-secondary">Due: {due}</p>
      <Button className="mt-4 w-full">View task</Button>
    </article>
  )
}

Look at the classes on the article: rounded-card, bg-surface, p-card. Every one is a named variable. The badge shows Done or Open depending on the done prop, and the last line is your own Button, which was already in the codebase:

import type { ButtonHTMLAttributes } from 'react'

// Already in the codebase. Code Connect maps the Figma "Button" component to this file.
export function Button({ className = '', ...props }: ButtonHTMLAttributes<HTMLButtonElement>) {
  return (
    <button
      className={`rounded-lg bg-brand px-4 py-2 text-sm font-semibold text-white hover:opacity-90 ${className}`}
      {...props}
    />
  )
}

The card, rendered

App.tsx renders two cards from the same component:

import { TaskCard } from './TaskCard'

export default function App() {
  return (
    <main className="flex flex-wrap gap-6 p-8">
      <TaskCard title="Write report" owner="Emma" due="Friday" />
      <TaskCard title="Email Jack" owner="Priya" due="Monday" done />
    </main>
  )
}

Run it with npm install and npm run dev, then open the address Vite prints (http://localhost:5173).

Two task cards side by side on a light grey page. Left: Write report, owner Emma, due Friday, with a blue Open badge. Right: Email Jack, owner Priya, due Monday, with a green Done badge. Both have a full-width indigo View task button.
Two cards, one component. The Done badge turns green from the done prop, and both buttons are the existing Button.

Try the token idea yourself: change --color-brand in src/index.css and watch every card follow.

Code to design: write it back

Now the other direction. Start from src/TaskCard.tsx and ask:

Take src/TaskCard.tsx and write it into my Figma file as a new frame named
TaskCard, with layers for the title, the badge and the button. Bind the colours
and radius to the matching Figma variables.

The agent uses a write tool. Which one depends on the task: use_figma creates and edits content in a file, and generate_figma_design sends a web page into Figma as layers. The result is a new frame on the canvas with layers for the title, the badge and the button. Because the same names go back, the frame stays bound to the variables.

DirectionToolsResult
Design to codeget_design_context, get_variable_defsA component in your repo
Code to designuse_figma, generate_figma_designA new frame in Figma
Keeps them alignedget_code_connect_map, add_code_connect_mapFrame and file point to each other

Common mistakes

  • Pasting a screenshot when the file is available. The agent guesses colours and spacing from pixels. Through MCP it reads the real values.
  • Vague variable names. Clear names like text-secondary give the agent better answers than grey-2.
  • Accepting hex colours in the component. If you see #4F46E5 in TaskCard.tsx, ask the agent to use the token.
  • Skipping the review. An agent can make mistakes in both directions. Check the component and the new frame.
  • Expecting write-back on any seat. Writing needs the remote server and the right Figma seat.

Quick recap

StepWhat happens
Connect.vscode/mcp.json or claude mcp add --transport http figma ..., then sign in once
ReadDesign context, variable definitions and the Code Connect map
BuildA component made of named tokens that reuses your own Button
Write backA new Figma frame bound to the same variables

Try it yourself

Add a priority variable in Figma, ask the agent to show it as a second badge on the card, then write the updated card back into Figma and check that the new layer is bound to the variable.

The project files and sample prompts for this lesson are in the StudyEasy AI Community, free to join.

Tried the exercise? Share your answer or ask a question.

The StudyEasy AI Community is free to join, with the lesson files, notebooks and code.

Join free on Skool

Keep going in React · 34 of 59

Previous
Components, Variants and Variables: One Design System in Figma and in CSS
Next post
Claude Design: From a Brief to a Clickable Prototype, Then Hand It Off to Claude Code

Related course on Udemy

The Python Architect Masterclass: Full Stack to AI Engineer

Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)

Related posts

One Request, Two Answers: the Same Post as an HTML Page and as JSON

Ask a Django blog for the same post twice: once as a 12,731-byte HTML page built by a template, once as 2,976 bytes of JSON built by a serializer. Compare the headers, see who builds the page, and why the server still owns every write.

A Blog Design from a Prompt: Downloading Figma Make Code and Reading App.tsx and BlogCard.tsx

Make a blog design from a prompt in Figma Make, download src.zip, unzip it with Python's zipfile module, and read the two files that matter: App.tsx with its selectedPost state and BlogCard.tsx with its props.

How a Web Page Works: HTML Tags, Elements and Attributes

A web page is a text file full of labelled pieces. Learn tags, attributes and nesting with three tiny pages, and see what breaks when an attribute or a closing tag is wrong.

Semantic HTML: header, nav, main, aside and footer as Page Landmarks

The same page written as div soup and with semantic tags looks identical, but only one gives screen readers and search engines landmarks and an outline. Plus tables, div, span and the one-main rule.

On this page

  • Connect the server once
  • Design to code: the agent reads
  • Variables become tokens
  • TaskCard.tsx: built from names
  • The card, rendered
  • Code to design: write it back
  • Common mistakes
  • Quick recap
  • Try it yourself
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

The Python Architect Masterclass: Full Stack to AI Engineer

Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact us
Legal
Terms of UsePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.