Auto layout

Build buttons, cards and lists that resize themselves, using direction, gap, padding and hug, fill or fixed sizing.

Module 4: Components and systems · Lesson 11 of 19 · 18 min read · Free

Without auto layout, changing a button label from "Pay" to "Pay ₦12,500" means resizing the button by hand, re-centring the text and moving everything below it. Multiply that by fifty screens and you'll see why professional designers use auto layout for almost everything.

Auto layout turns a frame into a smart container. It arranges its children in a row or a column, with fixed gaps and padding, and grows or shrinks as the content changes. It's also very close to how developers build layouts in code (CSS flexbox), so designs made with auto layout are easier to build exactly.

Your first auto layout: a button

  1. Type a label: "Pay now".
  2. Select it and press Shift + A. Figma wraps it in an auto layout frame.
  3. In the right sidebar, set padding (e.g. 24 px left and right, 14 px top and bottom), a fill colour and a corner radius.
  4. Change the text to "Pay ₦12,500". The button grows by itself, and the padding stays exactly the same.

The settings that matter

Auto layout: direction, gap, padding and sizing
  • Direction: horizontal (a row), vertical (a column) or wrap (items flow onto new lines, like tags).
  • Gap: the space between items. Use your 8-point scale.
  • Padding: the space between the frame's edge and its contents.
  • Alignment: where items sit inside the frame: left, centre, right, top, bottom.

Hug, fill or fixed

Every layer inside, and the frame itself, has a width and height setting:

  • Hug contents: as big as what's inside, plus padding. Buttons usually hug their text horizontally.
  • Fill container: stretch to fill the space the parent gives it. A full-width Pay button fills its parent; a text block in a card fills the card's width so it wraps neatly.
  • Fixed: an exact size that doesn't change, like a 48 × 48 icon button.

A hugging button's width is easy to predict: padding left + icon + gap + text + padding right. With an 88 px label, a 20 px icon, an 8 px gap and 24 px padding each side, that's 24 + 20 + 8 + 88 + 24 = 164 px.

Nesting: how real screens are built

Real screens are auto layouts inside auto layouts:

  • A list row is a horizontal auto layout: image, then a vertical stack (name and price), then a quantity control.
  • The list is a vertical auto layout of rows with a 12 px gap.
  • The screen is a vertical auto layout: header, list, summary card, Pay button.

Add an item to the list and everything below moves down by itself. Delete one and the gap closes. Make the text bigger and the rows grow.

Check yourself

Answer in your head first, then open each question to see the answer and why.

  1. Which shortcut adds auto layout to the selection?

    • A Shift + A
    • B Ctrl + P
    • C Alt + F4
    • D Shift + 1
    Show the answer

    A) Shift + A — Shift + A wraps the selection in an auto layout frame, or adds auto layout to a frame.

  2. A full-width Pay button should stretch to the width of its parent. Which sizing should it use?

    • A Fill container
    • B Hug contents
    • C Fixed, 48 px
    • D Absolute position
    Show the answer

    A) Fill container — Fill container stretches a layer to use the space its parent gives it.

  3. A hugging button has 16 px padding on each side, a 24 px icon, an 8 px gap and an 80 px label. How wide is it?

    • A 144 px
    • B 120 px
    • C 128 px
    • D 112 px
    Show the answer

    A) 144 px — 16 + 24 + 8 + 80 + 16 = 144 px.

More free lessons: What UI and UX designers actually do · Understanding users without fooling yourself · Layout grids and 8-point spacing · Clickable prototypes · Case studies and your portfolio