Skip to content
Tutorials Center
My learning

Topics

Lesson 18 of 36 ยท Auto Layout and Constraints

Nested Auto Layout, Wrap and Building Real Layouts

Combine auto layout frames inside each other, use wrap for card grids, absolute positioning and min/max sizes to build a real responsive page, with runnable stand-ins.

A single auto layout frame is useful, but real screens come from nesting them: a vertical page containing horizontal rows, containing vertical cards, containing small horizontal pieces. This lesson shows how to think in nested boxes, use wrap for responsive grids of cards, and avoid the pitfalls that make layouts brittle. It builds directly on Auto Layout Basics and Hug, Fill and Fixed Sizing.

Think in boxes

Before building, sketch the layout as nested rectangles. For a product listing page:

  • Page (vertical): header, content, footer.
  • Content (horizontal): sidebar (fixed width) + results (fill).
  • Results (vertical): title row + grid of cards.
  • Card (vertical): image, text block, button.
  • Text block (vertical): title, price.

Each level is an auto layout frame with its own direction, gap and padding. The skill is choosing the right boxes, not many boxes: ask of each one, "Does it need its own direction, gap or alignment?"

Layouts are nested boxes

Page Vertical stack
Content row Sidebar plus results
Card grid Wrapping row
Card Image, text, button

Each box has its own rules

1 / 2

Building from the inside out

  1. Create the smallest pieces (a title and a price).
  2. Select them and press Shift+A to make a vertical Text block.
  3. Add the image and button, select all three, press Shift+A to create Card.
  4. Set the card's width, padding, gap and fill.
  5. Select several cards and press Shift+A, then switch the direction to horizontal; the Grid appears.

Wrapping selected layers in a new auto layout frame is faster than creating the frame and dragging things in.

Alignment and gap per level

Different levels need different rules. In the card, the vertical gap might be 12; in the text block, 4; in the grid, 24. Resist using one gap everywhere: use the spacing scale and let related items sit closer than unrelated ones. That is proximity, a core design principle: gap tells the eye what belongs together.

Wrap

For a grid that reflows, set the horizontal auto layout to wrap: choose the Wrap direction (the icon with the arrow bending around), and Figma moves items onto a new line when they do not fit. Then:

  • Set horizontal gap and vertical gap (row spacing) separately.
  • Make the container width fixed or fill, so it has a width to wrap against.
  • Give each card a fixed width, or use a min width if the cards should grow to fill the row.

Resize the container and the number of columns changes, exactly like cards on a responsive website.

How wrapping works: a stand-in

This stand-in places cards in rows given a container width. It is plain Python, a model of the rule, not Figma code.

Python Stand-in: wrap cards into rows

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

At 1000 px, three cards fit per row (240 x 3 + 2 x 24 = 768 and a fourth would need 1032). At 480 px only one fits, so the grid becomes a single column and gets taller, just as in the editor.

Real page example: spacing totals

Here is another calculation, a vertical page whose height is the sum of its sections, so you can see what Hug does at the top level.

Python Stand-in: total height of a nested page

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

If you hide the hero in Figma (the eye icon), the page's height drops by the hero height plus one gap, again without moving anything by hand.

Absolute position inside nested layouts

Overlays such as a badge, a ribbon or a close button on a card should be absolutely positioned so they do not take part in the layout. With the child selected, choose Ignore auto layout in the Layout section, then set constraints (for example Top, Right) and drag it into place. Absolute elements still scroll and clip with the parent.

Common problems and fixes

Symptom Likely cause Fix
A child will not stretch Its parent hugs the content Make the parent fixed or fill
Text does not wrap Text layer is auto width Set auto height with Fill width
Gap looks double Both padding and gap used Choose one source of space
A card shrinks too much No min width Add a min width
Extra space at the bottom A child has fixed height Switch it to Hug

Name every auto layout frame by purpose (Card list, Price row). Dozens of frames called Frame 218 are impossible to maintain.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the main idea of nested auto layout?

    Complex layouts are built from simple boxes inside boxes.
  2. 2. Which setting makes a row of cards reflow onto new lines?

    Wrap moves items to a new line when they do not fit.
  3. 3. Three 240 px cards with 24 px gaps need how much horizontal space?

    3 x 240 + 2 x 24 = 768.
  4. 4. How should a notification badge on a card be placed?

    Overlays should not take part in the flow.

Summary

  • Build layouts as nested auto layout boxes, from the smallest piece outward.
  • Use Shift+A on selected layers to wrap them in a new container.
  • Wrap makes card grids reflow; set separate horizontal and vertical gaps and give cards fixed or min widths.
  • Absolute-positioned children handle overlays; name every frame.

Next: Components and Instances