Skip to content
Tutorials Center
My learning

Topics

Lesson 16 of 36 ยท Auto Layout and Constraints

Hug, Fill and Fixed: Resizing Rules in Auto Layout

Understand Figma's three sizing modes (hug contents, fill container, fixed), min and max sizes, and how they combine, with a runnable stand-in that distributes space.

Auto layout has two kinds of rules: how items are arranged (direction, gap, padding) and how each item is sized. The second set is where most confusion happens. Every auto layout frame and every child has a width and a height, and each can be set to Hug contents, Fill container or Fixed. Understanding these three modes lets you build buttons, cards and toolbars that behave correctly when text or screen size changes.

The three modes

Select an auto layout container or one of its children and look at the Width and Height fields. The drop-down beside each (or the small labels below the numbers) offers:

Three sizing modes

Hug contents Shrinks to fit children
Fill container Grows to use free space
Fixed A number you choose

Set per axis: width and height

1 / 2
  • Hug contents: the element's size equals its children plus padding. A button hugging its label grows when you type a longer label.
  • Fill container: the element expands to take the available space in its parent. If several siblings fill, they share the free space equally.
  • Fixed: the size is whatever number you typed, regardless of content.

Hug is available on frames with auto layout and on text layers (where it means auto width or auto height). Fill container only appears on children of an auto layout frame, because a frame needs a parent with rules to fill.

Combining modes

Width and height are independent. Common combinations:

Element Width Height
Button Hug Hug
Input field in a form column Fill Hug
Sidebar Fixed (280) Fill
Page content column Fill (with max width) Hug
Avatar Fixed (48) Fixed (48)

A useful mantra: containers hug, and children fill. A form is a vertical auto layout whose width is fixed (or fills the screen); every input inside fills the form's width and hugs its own height.

Do not let a parent hug its children while the children fill the parent: each would wait for the other to decide. Figma flags such a loop by changing one of them, and you will see the mode snap back. Break the circle by making the parent fixed or by making the child fixed.

Min and max sizes

Open the small menu next to width or height and add a minimum or maximum size. Examples:

  • A text column that fills its container but never exceeds max width 640 keeps lines readable on wide screens.
  • A button that hugs its label but has min width 96 never looks tiny.

Min and max apply in a prototype and in a responsive frame resize; they are an excellent way to describe design intent for developers, who map them to min-width and max-width in CSS.

Distributing space between fillers

When several siblings fill container, free space is divided equally (unless they have different min/max limits). The rest is simple arithmetic, and the stand-in below shows it. It is plain Python and not Figma code.

Python Stand-in: filling siblings share free space

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 800 px wide the Search box gets 584 px and at 1200 px wide it gets 984 px. Fixed items never change; the filler absorbs the difference. Two fillers would split the remainder 50/50.

Hugging text

A button that hugs its label is the classic example. The stand-in below estimates how wide the button becomes. Real text width depends on the font, so this uses an average character width: a rough estimate, not what Figma measures.

Python Stand-in: a hugging button estimate

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.

Short labels hit the minimum width of 96 while long labels grow the button. If the label is long enough you may want to wrap the text or set a max width, which brings truncation into play.

Truncating and wrapping text

Text inside a container that fills its parent can wrap onto more lines if the text layer uses auto height and fills the width. If you prefer a single line, use the text options Truncate text (ellipsis) and optionally set a max lines value. Test with a long German word or a very long name to see how the design copes.

Practical recipe: a list row

  1. Create a horizontal auto layout named Row: width Fill, height Hug, padding 12, gap 12.
  2. Add an Avatar (fixed 40 by 40).
  3. Add a vertical auto layout Text (width Fill, height Hug) with name and subtitle.
  4. Add a Chevron icon (fixed 24).

Resize the screen frame and the text block absorbs the change: the avatar and chevron stay put.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which mode lets a button grow when its label gets longer?

    Hug sizes the container to its children plus padding.
  2. 2. Where does Fill container appear?

    A layer can fill only if its parent is an auto layout frame.
  3. 3. Two siblings both fill a 400 px free space. How much does each get?

    Equal shares: 400 / 2 = 200 each (before min/max limits).
  4. 4. Why set a max width on a text column?

    Very long lines are hard to read.

Summary

  • Hug shrinks to fit, Fill grows to take free space, Fixed uses a number.
  • Width and height are set separately; containers usually hug and children fill.
  • Min and max sizes express responsive intent.
  • Fillers split leftover space equally.

Next: Constraints and Responsive Resizing