Stitch to Figma to Code: Turn a Stitch Screen Into Code That Uses Your Tokens
A Stitch export is full of hard-coded values like bg-[#F8FAFC] and rounded-[10px]. Map them to your own tokens (bg-surface, rounded-card, bg-brand) through Figma variables, a Tailwind @theme inline block, or the Stitch MCP server, then fix states, accessibility and data by hand.
What you will learn
- Name the three roads from a Stitch screen to code: via Figma, via HTML and Tailwind, via the Stitch MCP server
- Swap hard-coded fills in Figma for your own variables
- Rewrite exported Tailwind arbitrary values like bg-[#4F46E5] as token classes with an @theme inline block
- List what you still fix by hand after any export: states, accessibility and real data
Before you start
- Google Stitch From a Sketch or Screenshot
- Basic Tailwind CSS classes
Google Stitch gives you a nice-looking screen fast. The question is how to get it into your project without dragging a pile of raw hex colours along with it. The answer in every case is the same: turn the screen into code that uses your own tokens. A token is just a named value, like the brand colour.
The example is a sprint card for Orbit, a sample team project app.
Draft, polish, build
The journey has three stops. You draft the screen fast in Stitch. You can polish it in Figma and connect it to your variables. And you end with code: React with Tailwind CSS 4. You don't always need the middle stop, so there are three roads:
bg-brand, not bg-[#4F46E5].The screen used in the lesson came from a Stitch prompt like this one:
Design a sprint card for Orbit, a team project-management app. It shows the sprint name, how many tasks are left, and an "Open board" button. Clean, light theme, indigo accent.
Road 1: through Figma, swap hard-coded colours for variables
Stitch can send a screen to Figma. Once it's there, select the button: its fill is a plain colour, a hard-coded value. Your job is to swap each one for your own variable. The hard-coded indigo becomes color/brand, the light grey becomes color/surface, and the dark blue becomes color/ink. Figma's panels change often, so look for the fill and the variable picker rather than an exact menu name.
You can ask an AI assistant in Figma to do the swap for you:
Take the selected frame and replace every hard-coded fill and corner radius with the matching variable from our Orbit variables: color/brand, color/surface, color/ink, color/muted and radius/card. List anything that has no match.
Why bother? Because now a brand change is one edit, not fifty. Variables in Figma are covered in more depth in Components, Variants and Variables.
Road 2: HTML and Tailwind, map the classes to our theme
Stitch can also export a screen as HTML with Tailwind classes. This is the sprint card as exported, from the project's before/index.html:
<!-- Exported as-is: every colour and radius is hard-coded -->
<div class="bg-[#F8FAFC] rounded-[10px] p-4 max-w-sm">
<h3 class="text-[#0F172A] font-semibold">Sprint 12</h3>
<p class="text-[#475569] text-sm">8 tasks left, 3 due this week</p>
<button class="bg-[#4F46E5] text-white rounded-[10px] px-4 py-2 mt-3">
Open board
</button>
</div>
Every colour and every size is an arbitrary value in square brackets. Map them to names:
| Exported | Token class |
|---|---|
bg-[#F8FAFC] | bg-surface |
rounded-[10px] | rounded-card |
text-[#0F172A] | text-ink |
text-[#475569] | text-muted |
bg-[#4F46E5] | bg-brand |
The same card, from after/index.html:
<!-- Same card, now written with our tokens -->
<div class="bg-surface rounded-card p-4 max-w-sm">
<h3 class="text-ink font-semibold">Sprint 12</h3>
<p class="text-muted text-sm">8 tasks left, 3 due this week</p>
<button class="bg-brand text-white rounded-card px-4 py-2 mt-3">
Open board
</button>
</div>
Where do these names come from? From after/tokens.css. First, plain CSS variables in :root. Then an @theme inline block, which tells Tailwind 4 about them, so bg-brand reads the --brand variable:
@import "tailwindcss";
/* Orbit design tokens: the one place the values live */
:root {
--brand: #4F46E5;
--surface: #F8FAFC;
--ink: #0F172A;
--muted: #475569;
--card-radius: 10px;
}
/* Tell Tailwind about them, so bg-brand, text-ink and rounded-card exist */
@theme inline {
--color-brand: var(--brand);
--color-surface: var(--surface);
--color-ink: var(--ink);
--color-muted: var(--muted);
--radius-card: var(--card-radius);
}
The look is the same. The values now live in one place. The prompt for this mapping:
Here is HTML exported from Stitch (see before/index.html). Rewrite it for Tailwind CSS 4 using our tokens only: bg-brand, bg-surface, text-ink, text-muted, rounded-card. Do not keep any arbitrary values like bg-[#4F46E5]. Also give me the @theme inline block that defines the tokens from CSS variables.
Road 3: the Stitch MCP server pulls the screen for you
The fastest road is the Stitch MCP server. MCP is a plug that lets one tool talk to another. You tell your AI coding tool to build the Orbit dashboard from your Stitch screen with your tokens:
Using the Stitch MCP server, read my Orbit dashboard screen and build Dashboard.tsx in React 19 with Tailwind CSS 4. Use our tokens, not the raw colours. Then list what I still need to add: hover and focus states, empty and error states, accessibility labels, and real data.
The agent reads the screen from Stitch by itself (a header, three stat cards and a task list) and writes the file using bg-surface, text-ink and bg-brand. No export, no copy and paste. The exact wording you see depends on your tool. The same idea with Figma is shown in Figma MCP Server: Design to Code and Back.
What you still fix by hand
Whichever road you take, the export is a first draft. Three things always need you:
- States. The design shows one look, but a button also needs hover and focus, and a list needs an empty state and an error state. See States and Feedback.
- Accessibility. Check colour contrast, labels, and whether you can use it with a keyboard.
- Real data. The export has sample text, like names and numbers. Your app needs data from your own code.
A review prompt that covers them:
Check Dashboard.tsx for colour contrast, keyboard access, missing labels and hard-coded sample text. List the fixes, most important first.
Quick recap
| Road | What you do | Result |
|---|---|---|
| Via Figma | Swap hard-coded fills for variables | A design bound to color/brand, color/surface, color/ink |
| HTML + Tailwind | Map arbitrary values to token classes, add @theme inline | bg-surface, rounded-card, bg-brand |
| Stitch MCP | Let the agent read the screen | A component written with your tokens |
The design is a draft. The tokens are yours.
Try it yourself
Open before/index.html and find every hard-coded value. Rewrite the card with the tokens, compare it with after/index.html, then change --brand once and watch the whole card follow.
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.
