Reading a Figma file
6 minMost of a Figma file already reads like code. Learn which panel setting becomes which line of CSS or React, using a Zomato restaurant card rebuilt in Figma.
Lesson video
Tastebud · 5:42 · Captions on screen
Auto layout becomes flex, variables become CSS variables, and components become React components with props.
- Why. Figma built auto layout to mirror how the web lays out pages, so most panel settings have a CSS twin. Reading a setting is exact; measuring pixels is a guess.
- Real example. Select a layer in Dev Mode and the code panel writes each variable as a reference. Figma's own example is font-weight: var(--Thin-100, 100). (Figma Dev Mode, Nov 2026)
- When to break it. An art-directed hero with photos overlapping on purpose really is fixed spots. There, Ignore auto layout in Figma and position: absolute in CSS match one to one.
- Common mistake. Copying the canvas by eye. A measured gap turns into margin-top: 13px, a fill variable turns into #FFFFFF, and the build drifts from the file at its first change.
Our take. Read the layers panel before the canvas. If a frame has no auto layout, ask the designer to add it before you write a line, because code copied from coordinates breaks at the first long restaurant name.
- Card: auto layout, vertical, gap 8, padding 12
- Name: Fill container
- Rating badge: Hug contents
- Place row: Gap Auto (Between)
- Fill: the surface/card variable
- Badge: RatingBadge, Tone Positive, Value 4.5
- display: flex; flex-direction: column; gap: 8px; padding: 12px
- flex: 1
- No width in the flex row, so the content decides
- justify-content: space-between
- background: var(--surface-card)
- <RatingBadge tone="positive" value="4.5" />
Card recreated from Zomato's Bengaluru dining list, Nov 2026. The Figma layers are our rebuild, and the code is ours, written from the panel.
Without auto layout, the code can only copy coordinates
A frame without auto layout stores each layer as an x and a y, so code copied from it is position: absolute everywhere. Ask for auto layout first, and a longer restaurant name pushes things along instead of overlapping them.
- Each layer keeps an x and a y
- Code: position: absolute; top: 212px; left: 12px
- A longer name runs under the rating badge
- Layers keep an order, a gap and padding
- Code: display: flex; gap: 8px
- A longer name wraps and the badge stays clear
Our rebuild of a Zomato card, Nov 2026. The left column is what you get when you measure.
Variables become CSS variables, and modes become themes
Dev Mode refers to a variable as var(--name, value), and CSS uses the value after the comma only as a fallback. You can set its exact Web name. Each mode, such as Light and Dark, becomes one set of values for the same names.
One Figma variable becomes one CSS variable with a value per theme
- Variable surface/card. A colour variable in a collection with two modes: Light #FFFFFF and Dark #1C1C1C.
- Set its Web code syntax. Type the name your codebase uses, such as var(--surface-card). Without one, Dev Mode turns the variable's name into a valid CSS name for you.
- Dev Mode shows a var() reference. In the form Figma documents, var(--name, value), as in its own example font-weight: var(--Thin-100, 100).
- CSS: :root and [data-theme=dark]. Each mode becomes one block of values. Components only ever use the name.
Components become React components, and properties become props
Each component property type has a code twin. Code Connect records the mapping, so Dev Mode shows your real component's code in place of generated code, and the Figma MCP server passes it to coding agents.
Each Figma property type maps to one kind of React prop
- Variant: Tone → tone. Positive or Neutral becomes tone="positive" or "neutral", one value from a fixed list. Code Connect maps it with figma.enum.
- Text: Value → value. 4.5 becomes value="4.5", a string. Code Connect maps it with figma.string.
- Boolean: Show icon → showIcon. On or off becomes true or false. Code Connect maps it with figma.boolean.
- Instance swap: Icon → icon. The chosen icon becomes icon={<StarIcon />}, a component passed as a prop. Code Connect maps it with figma.instance.
Try it
Click a layer, see its code
Pick a layer from our Figma rebuild of a Zomato restaurant card (Punjab Grill, 4.5, ₹2,000 for two). Each one shows its panel settings and the code we wrote from them.
Figma: auto layout, vertical, gap 8, padding 12, width Fixed 320, fill surface/card. CSS: display: flex; flex-direction: column; gap: 8px; padding: 12px; width: 320px; background: var(--surface-card). Rows set to Fill container stretch across it, which is align-self: stretch.
Quick check
A card's place row is set to Gap: Auto (Between), with the area on the left and the distance on the right. Which CSS matches it?
Watch next
Watch it for How each auto layout setting lines up with flexbox. When it calls them exactly the same, remember the stroke and Ignore auto layout cases from this lesson.
Watch it for How a coding agent builds a section from the file's own variables and components, which only works when the file is set up the way this lesson describes.
Connects to: 3.2 Flexbox · 6.2 Props and composition · 7.2 Figma variables to CSS variables · 13.5 Coding agents in a real codebase · 15.2 SwiftUI layout
Sources · checked Nov 2026
- Figma Help: Use auto layout with CSS Flexbox in mind'Auto layout was designed to mirror how the web renders layouts, but a few edge cases never quite matched CSS'; the updated version is the default for new frames from July 2026; a center or outside stroke behaves like an outline and is excluded from layout, an inside stroke like a border; Between matches space-between; code copied from Dev Mode maps more directly to flexbox
- Figma Help: Guide to auto layoutVertical, horizontal, wrap and grid flows; resizing Fixed width/height ('Object size stays fixed'), Hug contents ('Object resizes based on its child objects') and Fill container ('Object fills all available space'); gap set to Auto with Between, Around or Evenly; padding; Ignore auto layout, formerly absolute position, 'much like absolute position in CSS'
- Figma Help: Overview of variables, collections and modesVariables are raw values that can change with context; types Color, Number, String, Boolean, Timing and Easing; 'A mode is a list of values for a variable in a collection, storing one value per variable'; light and dark themes as a use
- Figma Help: Guide to variables in FigmaCode syntax gives a variable one name per platform (Web, Android, iOS); it appears in Dev Mode code snippets, which support CSS, SwiftUI and Compose
- Figma Help: Variables in Dev ModeDev Mode gives a reference to the variable, as in font-weight: var(--Thin-100, 100), and normalizes variable names into valid CSS names
- Figma Help: Explore component propertiesComponent property types: Boolean, Instance swap, Text, Variant and Slot
- Figma Developer Docs: Code Connect for Reactfigma.enum maps a variant, figma.boolean a boolean, figma.string a text property and figma.instance an instance swap to React props; figma.slot maps slots
- Figma Developer Docs: Code ConnectCode Connect shows true-to-production code snippets from your design system in Dev Mode in place of autogenerated examples, and gives the Figma MCP server references to your actual code; Dev or Full seat on Professional, Organization and Enterprise plans
- Figma Help: Guide to Dev ModeDev Mode is on Professional, Education, Organization, Government and Enterprise plans; the code view shows autogenerated code snippets for a selected layer
- Figma: PricingA Dev seat on the Professional plan is $12 a month
- MDN: var()The second argument of var() is a fallback value, used when the custom property isn't defined
- Figma Help: Guide to the Figma MCP serverThe MCP server gives AI agents design context to generate code from Figma files and can write back to the canvas; listed for all plans; Code Connect keeps generated code consistent with your codebase
- Zomato: Restaurants in Bengaluru (dining list)The card wording: Flat 15% OFF, Punjab Grill, 4.5, North Indian, Kebab, Biryani, Mughlai, ₹2,000 for two, Brigade Road, Bangalore, 1.3 km
- npm: @figma/code-connectCode Connect 2.1.1, published 23 Nov 2026
- Web Platform Status: Flexbox gapgap in flexbox is Baseline widely available, as are flexbox and custom properties