No history yet

Mastering Auto Layout

Mastering Auto Layout

You've learned the basics of Auto Layout, but now it's time to unlock its full potential. Mastering its advanced features will transform your designs from static mockups into dynamic, responsive systems. We'll move beyond simple stacking and explore how to make components that truly adapt to their content and screen size, just like they would in a live application.

Figma Auto Layout lets you create flexible UI components that adapt automatically to content changes, screen sizes, or user interactions.

Let's start by understanding the three core resizing behaviors that control how objects behave inside an Auto Layout frame. Getting these right is the foundation for everything else.

Fixed, Hug, and Fill

Every item inside an Auto Layout frame has horizontal and vertical resizing settings. These settings determine how an object behaves when its parent frame or its sibling elements change size. You can think of it as giving instructions to your components.

BehaviorWhat It DoesBest For
FixedThe layer maintains a specific, unchanging width or height.Icons, avatars, or any element that should not resize.
Hug ContentsThe layer resizes to be just large enough to fit the content inside it.Buttons, tags, or text blocks that need to grow with their content.
Fill ContainerThe layer expands to fill the available space in its parent container.Backgrounds, flexible text areas, or creating space between elements.

For example, imagine a button with an icon and text. The button's frame should be set to "Hug contents" so it grows or shrinks if you change the text. The icon inside, however, should have a "Fixed" width and height so it always stays the same size. The text label could be set to "Fill container" if you wanted it to take up all the remaining space in the button.

This level of control is what makes Auto Layout so powerful. It directly mirrors how developers use Flexbox to build user interfaces in code, making for a smoother handoff.

Mastering the interplay between Hug, Fill, and Fixed is the key to creating truly responsive components in Figma.

Creating Responsive Grids with Wrap

In the past, creating a grid of items that would reflow based on screen size (like a gallery of photos) required complex nested frames. The "Wrap" alignment option solves this elegantly. When you apply Auto Layout to a group of objects and set the direction to 'Wrap', the items will automatically move to the next line when they run out of horizontal space.

This is incredibly useful for designing components like tag clouds, photo galleries, or navigation bars that need to adapt to different screen widths. Simply set the parent frame's horizontal resizing to "Fill Container" and its children to "Hug Contents". As you resize the parent, the children will wrap automatically.

Advanced Positioning

Auto Layout is fantastic for structured, linear layouts. But what about elements that need to break out of that flow, like a notification badge on an icon or a close button in the corner of a modal window? For this, you use Absolute Position.

Lesson image

When you apply Absolute Position to an element inside an Auto Layout frame, it's taken out of the normal layout flow. It no longer affects the position of its siblings. You can then pin it to any corner or edge of its parent frame using the constraints controls. This is perfect for UI decorations that need to stay in a fixed position relative to a parent container, regardless of how other elements reflow.

Another powerful technique is using negative spacing. If you set a negative value for the space between items in an Auto Layout frame, the items will overlap. This is ideal for creating stacked avatar lists or layered card effects.

Figma even lets you control the stacking order. The item that appears last in the Layers Panel will be on top. You can change this by clicking the three-dot menu in the Auto Layout panel and selecting "Canvas stacking" to control the order visually.

/* CSS equivalent of negative spacing for avatars */
.avatar-list .avatar:not(:first-child) {
  margin-left: -10px; /* Overlaps by 10 pixels */
}

Controlling Fluidity

Sometimes, you want a component to be flexible, but not too flexible. Setting min and max dimensions gives you precise control over how much an Auto Layout frame can stretch or shrink. For example, you can set a minimum width on a button to ensure its text is always readable, even on very small screens. Or, you could set a maximum width on a text block to prevent lines from becoming unreadably long on large monitors.

You can find these settings in the width and height input fields within the right-hand design panel. Click the dropdown arrow next to the dimension value to add a min or max width/height. This feature is crucial for creating robust, truly responsive designs that look great on any device.

Quiz Questions 1/5

You are designing a button with an icon and a text label. The button's width should adjust automatically based on the length of the text. Which horizontal resizing setting should be applied to the button's main Auto Layout frame?

Quiz Questions 2/5

Which Auto Layout feature allows you to create a grid of tags that reflows onto multiple lines as the screen width changes?

By mastering these advanced Auto Layout features—resizing behaviors, wrapping, absolute positioning, negative spacing, and min/max dimensions—you can build complex, adaptable components with confidence and precision.