EduFlow
UI Design with Figma
0%

Section 2 · Layout

Resizing: Hug, Fill, Fixed and Wrap

20 min4 min readChoose wisely

Lesson at a glance

Control how auto layout frames and their children size themselves with Hug contents, Fill container and Fixed, set min and max limits, wrap chips onto new lines, and pull badges out of the flow.

  1. 1Hug, Fill and Fixed
  2. 2Min and max
  3. 3Wrap
  4. 4Pulling a layer out of the flow

No video here — just the real thing: a written lesson, runnable examples, a quiz and practice.

Your habit row now stacks itself, but test it the way Sofia does: drag the Today frame wider. The rows stay at their old width, leaving a strip of empty screen on the right. Drag it narrower and the check buttons fall off the edge. Stacking is solved; sizing is not.

In auto layout every layer has two sizing behaviours, one for width and one for height. Get those right and the same row works on any phone, in any language, with any habit name.

Hug, Fill and Fixed

You set sizing in the width and height controls of the right sidebar. There are three options.

Hug contents makes a frame exactly as big as its children plus padding. A chip that hugs grows when its label changes from “Daily” to “Weekends”. Only frames and text can hug, because only they have contents.

Fill container makes a child take all the available space in its auto layout parent along that axis. If two siblings both fill, they share the space equally.

Fixed sets an exact size that never changes. Icons and the check button are fixed at 32 × 32 because a check target should not grow or shrink with the text next to it.

Three versions of a row. With the text stack on Hug, the check button sits right after the text. On Fill, the stack stretches and the button sits at the right edge. On Fixed, the stack is a set width and a long name is cut off. Hug Read Fill Read Fixed Read 20 pages be… Fill pushes the button to the edge; Fixed truncates long names.
The same habit row with three sizing choices for the text stack

For Steady’s habit row the settings are:

Layer Width Height
Habit row Fill container Hug contents
Icon, Check button Fixed 32 Fixed 32
Text stack Fill container Hug contents
Habit name, Streak Fill container Hug contents

Read it from the outside in. The row fills the list’s width. Inside it, the text stack fills whatever the icon and button leave, which pushes the button to the right edge. The habit name fills the stack’s width and hugs its height, so a long name wraps onto a second line and the row grows taller to fit. That is exactly the behaviour you want on a 375 px phone.

Figma enforces one rule for you: a parent cannot hug a child that fills it on the same axis. Each would be waiting to measure the other. If you set a child to Fill container, Figma switches the parent from Hug to Fixed on that axis.

Min and max

Fill and Hug can produce silly sizes at the extremes. A full-width button looks fine on a phone and ridiculous at 1,000 px wide on a tablet. A chip that hugs a one-letter label can become narrower than a fingertip.

Min and max width and height (found in the width and height dropdowns) set the limits. Steady uses:

  • Save habit button: Fill container, max width 480, so it stops growing on tablets.
  • Chip: Hug contents, min width 64, so short labels still make a comfortable target.
  • Text field: Fill container, min width 200, so it never collapses in a narrow layout.

Wrap

The frequency chips in the New habit sheet sit in a horizontal row. “Daily, Weekdays, Weekends, Custom” fits at 393 px but not at 320 px or in German. Turn on wrap for the row and chips that do not fit flow onto a new line instead of overflowing. At the time of writing, a wrapping frame lets you set the space between lines separately from the gap between items; use the same 8 px so the chips form an even grid.

Wrap is for collections of similar items such as chips, tags or avatars. Do not wrap a habit row: on a narrow screen its check button would drop onto its own line.

Pulling a layer out of the flow

Sometimes one child should not take part in the flow at all: a small flame badge on the corner of a habit icon, or a dot that marks an unread reminder. Select it and turn on Ignore auto layout (it was called absolute position until recently, so older tutorials use that name). The layer stays inside the frame but stops affecting its siblings, and you place it with constraints, here Right and Top, so it sticks to the corner when the icon resizes.

Your rows now adapt to width and content. Next you give all those gaps and paddings a system, so 12, 16 and 24 are decisions instead of guesses.

Key takeaways

  • Every layer in auto layout has a width and a height behaviour; Hug contents follows the children, Fill container takes the parent’s available space, Fixed never changes.
  • A parent cannot hug a child that fills it on the same axis, so Figma switches that parent to Fixed.
  • Min and max width stop components from becoming absurdly narrow or wide on unusual screens.
  • Wrap lets horizontal content such as chips flow onto a new line instead of overflowing.
  • Ignore auto layout takes one child out of the flow so you can position it with constraints, which suits badges and floating dots.

Further reading

Check your understanding

4 questions

Question 1 of 4

The primary “Save habit” button should stretch across the sheet on any phone, but stay its natural height. Which settings fit?

Question 2 of 4

Inside the habit row, the text stack is set to Hug contents. On a wide phone the check button sits right next to a short name instead of at the right edge. What fixes it?

Question 3 of 4

You set a card’s width to Hug contents, then set a child inside it to Fill container on the same axis. What does Figma do?

Question 4 of 4

Steady shows a small flame badge overlapping the top-right corner of a habit’s icon. How do you build it inside the auto layout icon frame?

Practice

Choose wisely

Make the New habit sheet survive any screen

QA filed three bugs against the New habit sheet: on a 320 px phone the chips run off the edge (below), the Reminder toggle hugs its label instead of sitting at the right edge, and on an iPad the Save habit button stretches to 900 px wide.

:::figure The New habit sheet on a 320 px phone

A narrow bottom sheet. The name field fits. The four frequency chips run past the right edge of the sheet. The Reminder label is followed immediately by its toggle instead of the toggle sitting at the right edge. The Save habit button fits. New habit Habit name Daily Weekdays Weekends Custom Reminder Save habit :::

The sheet is a vertical auto layout frame set to Fill container width. Select every change that fixes one of these bugs properly.

Make the New habit sheet survive any screen