Skip to main content

08. Auto layout - Figma 101

Learn how to use auto layout so you can build responsive interface elements that adjust dynamically to content. Understand hug contents, fill container, spacing, and padding so you can create professional, scalable designs. This powerful feature means less manual resizing and more time focusing on the design details that matter.

Auto layout enables objects on your canvas to dynamically adjust based on the content inside allowing your designs to be responsive and flexible. Some of the most common use cases for auto-layout are any type of dynamic content that automatically adjusts based on content size, any responsive design elements that resize on different devices, any expandable or collapsible sections within a list, items that you need to be rearranged in a list, and really any data-driven content is a perfect use case for auto-layout, but it is important to note that while auto-layout can be a useful tool, even during the experimental phase of your design project, make sure it's actually enhancing your design process without making you feel creatively constrained. It's all about finding balance, and if you start feeling uncomfortable or confined, it might be a sign that you're overusing auto-layout, but when used appropriately, auto-layout can be super valuable and will help you quickly iterate designs and explore different layout possibilities. Let's start with creating an auto-layout button with a text field. Select the text and hit shift A to create an auto-layout frame around it.

Figma will automatically adjust the frame based on the hug content setting, which is the default. This means that the frame will resize according to the size of the content. You can see this in action by adding a fill to the frame to better visualize the background bounding box. Once you have the auto-layout frame, try changing the content of the text field. You'll notice that the frame will dynamically adjust its size based on the new text length demonstrating hug contents in action.

If you want to add a second item into the auto-layout frame, like an icon, we can drag it into the frame and Figma treats it as a part of the frame's content and the frame size will adjust accordingly. You might notice that the objects are not always perfectly aligned. This misalignment often happens because the bounding boxes of the different objects aren't the same height, which leads to uneven alignment when using the default align top-left setting. To fix this, you can adjust the alignment of your auto-layout frame in the properties panel with this salting cracker looking component. Figma is pretty clever, so when you hit shift A, Figma makes a quick decision on the orientation based on your initial setup.

Feel free to flip the orientation between horizontal and vertical as you need. The space between items is the amount of space between the items. You control how much breathing room each item gets from its neighbors. Crank up the value to give them plenty of space, or bring it down a notch for a cozy design. The padding section defaults to 10 and adds a buffer all around your items.

You can adjust the horizontal and vertical separately or altogether by holding command and clicking into the padding section. You can also click the individual padding icon and adjust them individually. Now let's explore the dynamic duo of auto-layout, fixed-width and fill-container. These features are the backbone of flexible design. The best visual example I found for remembering this concept is Figma's own water bottle.

We've got a fixed water bottle with fluid filling the container. This is essentially how fixed-width and fill-container work together. Imagine you're creating a navigation menu. The parent frame can have a fixed width with left and right constraints added. This means, it maintains a specific fixed-width regardless of the content that it contains.

On the other hand, the child frames can be set to fill container. This tells them to expand and occupy all available space within the parent frame. If you're having issues here, double check that both the child container and the text field inside are both set to fill-container. They'll grow and shrink, adapting to the size and dimensions of the container. Another great feature of auto-layout is how quickly you can rearrange items.

You can do this by dragging and dropping or by simply changing the layer order. As your designs progress more and more, you can combine multiple auto-layouts together to form quite complex components. But this is an intro to auto-layout so we can't go too deep on all of that. Mastering auto-layout is like acquiring a superpower for your first design toolkit, however, much like a fledgling superhero learning to harness their powers for the first time. Auto-layout must be used with discretion and within your own comfort zone.

Overuse can lead to unnecessary constraints, which will hamper your creative freedom, especially early on in a project. So like every superhero, fine tuning their abilities. Practice until auto-layout becomes your trusted sidekick in design, boosting your productivity and not holding you back.