All posts
Product design

Auto Layout in Figma: Designing Responsive Components That Match CSS

Figma auto layout mapped to CSS: how hug, fill, gap, padding, wrap and grid translate to flexbox and grid, so your responsive components build as designed.

By Mehdi Hassan7 min read

The short answer

Figma auto layout is a layout mode that stacks a frame's children in a row, a column, a wrapping row or a grid, with gap, padding and alignment rules. It maps closely to CSS: a horizontal auto layout frame is a flex row, hug means fit-content, fill means flex-grow, and grid auto layout means CSS grid.

Key takeaways

  • Auto layout is flexbox with a friendlier name. Design with that in mind and builds match the file.
  • Hug, fill and fixed are the three sizing rules developers need. Set them on purpose for every layer.
  • Use gap and padding instead of spacer rectangles. Spacers have no CSS equivalent worth keeping.
  • Min and max widths turn a fixed mockup into a responsive component without extra breakpoint frames.
  • Absolute position inside auto layout is position: absolute in code. Use it sparingly, for badges and overlays.

Part of Design-to-Development Handoff: How to Ship Designs Without Losing Detail

What is Figma auto layout and why does it matter for code?

Figma auto layout is a property you add to a frame so its children arrange themselves by rules instead of fixed coordinates. Add a child and the frame grows. Change a label and the button resizes. That behavior is the same idea as CSS flexbox and grid, which is why auto layout is the single most useful habit for designs that will be built.

Most tutorials stop at how to click the buttons. The gap they leave is the translation: what each setting becomes in CSS, and which settings have no clean equivalent. That translation is where a design-to-development handoff gains or loses detail, because a developer who reads a frame of absolute positions has to guess the rules you had in mind.

How does Figma auto layout map to CSS flexbox?

A horizontal or vertical auto layout frame maps to a flex container, and its settings map almost one to one. Here's the translation we use when we build from our own files.

Figma auto layout setting

CSS equivalent

Tailwind equivalent

Direction: horizontal

display: flex; flex-direction: row

flex flex-row

Direction: vertical

display: flex; flex-direction: column

flex flex-col

Wrap

flex-wrap: wrap, plus row-gap for vertical spacing

flex-wrap gap-y-4

Gap between items

gap

gap-4

Spacing mode: auto

justify-content: space-between

justify-between

Padding

padding (per side when values differ)

p-6, px-6, py-4

Alignment (9-point grid)

justify-content on the main axis, align-items on the cross axis

justify-start, items-center and similar

Text baseline alignment

align-items: baseline

items-baseline

Absolute position on a child

position: absolute inside a position: relative parent

absolute inside relative

Strokes included in layout

box-sizing: border-box

the default in Tailwind

Alignment is the setting that trips people most. Figma shows one nine-point control, but CSS splits it across two properties that swap meaning when direction changes. In a horizontal frame, left-to-right is justify-content. In a vertical frame, top-to-bottom is. Developers who know this read your alignment correctly first time.

What do hug, fill and fixed mean in CSS terms?

Hug, fill and fixed are resizing rules, and each one has a direct CSS meaning. Hug sizes a layer to its content, fill makes it take the remaining space, and fixed gives it an exact size. Set them deliberately on every layer, on both axes, because the defaults are often wrong for responsive work.

Figma resizing

On the main axis

On the cross axis

Hug contents

width: fit-content or flex: none

Sized to content, align-self as set

Fill container

flex: 1 1 0, so it grows and shrinks

align-self: stretch

Fixed width or height

width or height in px, flex-shrink: 0

An exact size

Min and max width

min-width and max-width

min-width and max-width

Two children set to fill split the space evenly, exactly like two flex: 1 items. A text layer set to fill wraps when the container narrows, while a text layer set to hug never wraps, which is why long button labels sometimes break layouts in the build but not in Figma. Choose fill for paragraphs and hug for labels.

When should you use grid auto layout instead of flexbox?

Use grid auto layout when items must line up in two directions at once, such as card grids, pricing tables and dashboard tiles. Figma's grid flow arranges children into rows and columns with column and row gaps, which maps to CSS display: grid with grid-template-columns. Flex-style auto layout only controls one direction, so rows of cards drift out of line when content heights differ.

A practical rule: if you would describe the layout as "three columns on desktop", it's a grid. If you'd describe it as "icon, label, then push the arrow to the right", it's flex. Grid features in Figma are newer than flex-style auto layout and still change, so check Figma's current help docs for which grid options your plan and file support before you build a library on them.

How do you make Figma responsive design match the build?

Figma responsive design comes from resizing rules, not from drawing every breakpoint. Build each component with fill and min or max widths, test it by dragging the frame narrower and wider, and only draw separate breakpoint frames where the layout genuinely changes, such as a sidebar that becomes a drawer.

  1. Build from the inside out

    Wrap the smallest groups first (icon plus label), then the card, then the section. Each level gets its own auto layout frame.

  2. Set resizing on both axes

    For every layer, decide hug, fill or fixed horizontally and vertically. Leave nothing on a default you didn't choose.

  3. Add min and max widths

    Give cards a minimum width and text blocks a maximum width, so the component behaves at sizes you didn't draw.

  4. Stress-test with real content

    Paste in the longest real label, a missing image and a translated string. Fix what breaks before handoff.

  5. Resize the parent frame

    Drag it from phone to desktop width. Anything that overlaps or overflows will do the same in the browser.

For breakpoint changes that resizing can't express, write them as rules instead of duplicating frames, using the same note format we describe in annotating designs for developers. It keeps the file small and the intent explicit.

What about constraints and frames without auto layout?

Constraints are the older system, and they still matter for children of frames that don't use auto layout. Left, right, center and scale constraints map roughly to absolute positioning with left, right or percentage values. They're fine for illustrations and decorative layers, but a page built mostly on constraints gives developers coordinates instead of rules.

Hypothetical example: translating a pricing card

For example, suppose a pricing card is a vertical auto layout frame with 24 px padding and a 16 px gap, set to fill width with a minimum width of 280 px. Inside it, the header row is horizontal with spacing mode auto, holding the plan name (hug) and a badge (hug). The feature list is vertical with an 8 px gap, and the button is set to fill width.

In code, that reads as a flex column with padding and gap, flex: 1 and min-width on the card, justify-content: space-between on the header, and width: 100% on the button. Three cards in a grid auto layout parent become a CSS grid with three columns that drops to one on small screens. Nothing in the build needs a guess.

How does auto layout fit into a component library?

Auto layout is what makes components reusable. A button whose padding and gap are rules can take any label, icon or size variant without manual nudging, and its properties can map to the same props in code. Pair it with variables for spacing and color, and the jump from Figma to Tailwind gets shorter.

Next, read how to structure a component library in Figma, how to sync Figma variables with Tailwind, and what Figma Dev Mode shows developers about your auto layout settings. If you'd rather start from files built this way, our $3,000 brand and design sprint delivers Figma components laid out with the same rules we build with.

Frequently asked questions

Is Figma auto layout the same as CSS flexbox?
Not exactly, but it's close enough that you should design as if it were. Direction, gap, padding, alignment, wrapping and grow or shrink behavior all have direct flexbox equivalents. The differences are in edge cases: Figma's alignment control combines two CSS properties, text sizing behaves slightly differently, and some CSS features such as order or flex-basis percentages have no visible control in Figma.
Should every frame in Figma use auto layout?
Almost every frame that holds interface content should. Buttons, cards, lists, forms, navigation and page sections all benefit, because they need to adapt to content. Illustrations, decorative compositions and image collages are the exception, since their pieces don't follow a flow. A useful check is whether a developer would build it with flex or grid. If so, use auto layout.
Why does my design look different in the browser than in Figma?
The usual causes are resizing rules left on defaults, text layers set to hug that should fill, fonts rendering at slightly different widths, and spacing done with nudged positions instead of gap and padding. Real content also differs from placeholder text. Test components with the longest real strings and resize their parent frames in Figma before handoff to catch most of these problems early.
Can developers see auto layout settings in Figma?
Yes. Selecting a layer in Figma's inspect panel, or in Dev Mode if your team uses it, shows layout direction, gap, padding, alignment and sizing, and can generate CSS for them. The generated code is a reference, not production code, but it confirms the rules you set. Clear auto layout makes that output far more useful than absolute positions.

· CEO & Design Director

Copywriter, designer and developer, and founder of Designify Studio. Over five years, 60+ projects across 14+ industries, for startups that have raised $300M+.

Want this done for you? Brand & design sprint, $3,000.

A brand refresh or redesign, plus design explorations for your website and product. $3,000, one-time, fixed price. Book a free 30-minute call to see if it fits.

Schedule Call