Auto Layout in Figma -Everything You Need to Know

Imran Sajib
UX Planet
Published in
8 min readAug 26, 2022

--

What is auto layout?

Auto layout is an amazing feature of Figma. Using Auto Layout, frames and components can be created in a very lively way. Height, Width, and positions of the elements can be adjusted automatically in a magical way using this amazing feature.

It allows you to create designs that can adjust their screens as their contents change and can grow or shrink to fit your container. Suppose you are making a button, you want the button to enlarge or shorten as you type text on them or you want the button text to adjust its position automatically maintaining its alignment and padding on four sides as you increase the height and width of the button. You can do that using auto layout feature on Figma. Sounds pretty magical, right?

Buttons made with auto layout

Additionally, the fact that this function changes an element’s size helps in the development of responsive interfaces. To adapt to various devices, you don’t need to design the same element in two distinct dimensions. Instead, you may create just one element and use the Auto Layout tool.

A card made using auto layout

Getting started with auto layout

Auto layout can be applied to anything. There are three ways to apply auto layout.

  1. Auto layout can be applied simply by pressing Shift + A after selecting the elements.
  2. An option to add Auto Layout appears in the Properties Panel (right bar), in the “Design” section when groups, frames, or any contents are selected.
  3. Auto layout can also be applied directly from the options that appeared when right click is pressed.

A quick introduction to the Auto layout properties

Elements can be organized easily by auto layout

Several elements can be aligned quickly using auto layout to improve the organization, and it consequently, facilitates and speeds up future prototyping when working with responsive design.

Quick direction Change

Besides aligning and organizing quickly, directions of the contents can be changed easily from vertical to horizontal and vice-versa from the auto layout properties.

To change the direction of the items on a frame, click on the arrows indicating horizontal and vertical direction.

Distribution

Once auto layout is applied, distribution mode determines how the objects within frame will be distributed. There are two modes of distribution-

Packed mode: Objects in a frame will be grouped together. Use this option to keep objects in a frame as close as possible and aligned together.

Space between: Objects in a frame have the space between them equally distributed along the direction and alignment set for the frame. Use this option to stretch objects across a frame.

To change distribution mode, Click the […] menu in auto layout properties to open advanced layout settings. Next to Spacing mode, use the dropdown to choose direction mode.

Shortcut: Click the alignment box and press X to toggle between space between and packed.

Alignment setting in Auto Layout

Elements are aligned automatically when auto layout is applied but what is more interesting is alignment is not restricted to just a single position in space. When elements of different sizes are grouped with Auto Layout, you can define whether to position them left, right, or center

When Auto layout is applied there is a small grid with 9 points In the properties panel right side of the design section, and on one of these points, there will be an icon of three bars in blue color. Each point is a different form of alignment.

Alignment basically depends on the distribution mode of the items.

Alignment setting in space between distribution mode: If your distribution is set to Space between, you have three options for each direction:

  1. Vertical auto layout: Left, Center, Right
  2. Horizontal auto layout: Top, Center, Bottom

Alignment setting in space between packed mode: If your distribution is set to Packed, you have the same nine options for each direction:
1. Top left
2. Top center
3. Top right
4. Left
5. Center
6. Right
7. Bottom left
8. Bottom center
9. Bottom right

Padding

Padding is an element’s inner margin. Padding controls the empty or white space between the boundary of an auto layout frame and the frame’s child objects on a variety of components, including the button itself. Paddings can be set uniformly, vertically, and horizontally, or have different values for top, right, bottom, and left padding. we use this to design the optimal vents.

Spacing between items

Now that you know how to work with paddings, it’s time to learn about the spacing between each item, whether it’s a normal layer, a group or a component, that is inside the element that has auto layout.

There are two options for applying auto layout. It can be done by selecting the group of cards on the side and type values ​​in the field of space between items.

It is also possible to modify it by clicking on one of the pink lines that will appear when clicking on the card, dragging freely, or clicking on the line, similar to what we did with padding before.

Resizing options

As you may have already noticed, the auto layout is a terrific tool for working with responsive design because it automates the process of altering a group or component.

In addition, there are three resizing tools that improve everything we’ve seen so far and are located below the width and height fields. Let’s talk about them in detail-

Fixed width/height:
The first choice, Fixed width/height, as the name suggests fixes the element’s current value at all times. The values of the frame’s dimensions remain constant regardless of the content when an auto layout frame’s width or height is set to Fixed. Like a string of text that varies in length, the size of the frame is unresponsive to changes in the objects contained within it.

Hug content
The second option is Hug content, which maintains proper paddings and gaps while allowing you to use Auto Layout to adjust the width or height of any internal elements within the group. To automatically resize itself in accordance with its child objects, set an auto layout frame to Hug content. While obeying the padding value, the frame will maintain the smallest possible size to encircle the objects within it.

Note that the parent frame will no longer hug the contents and will instead become Fixed for the axis if any child items inside an auto layout frame are set to Fill container.

Fill container
The third and last option is the Fill container, If an auto layout frame’s Fill container setting is used, objects will stretch to fill the width and/or height of their parent frame maintaining the padding and spacing specified.

Resizing in constraints

If an object’s absolute position is not enabled, you cannot apply constraints to its child objects in an auto layout frame. But you can specify how items behave when the frame or the objects within it resizes by using the resizing function.

If the auto layout frame is contained inside another frame, you can still add constraints to the auto layout frame itself. It will then be possible for you to specify the limitations for the Auto layout frame as well as the resizing options for any items contained inside it.

Change the settings in the constraints menu to determine in which position objects should remain fixed while resizing the frame.

Absolute position

When a position is selected as absolute, you can identify where you specifically want that element to be, regardless of how many pixels wide or tall your device is.
You’ve seen that when working with Auto Layout, what it does is allow you to organize various elements that are grouped together more easily and that you can’t move them freely when this is applied. Or at least, not without Position absolute enabled.
To activate, select any layer, group, or component within a group with Auto Layout, and activate the option located to the right of the “Y” field in the Design Panel on the right.

Text Baseline Alignment

When text is combined with an object, such as a button and an icon, and layers with different heights are placed vertically centered and positioned in a horizontal auto layout, the Text baseline aligns them beautifully.
To enable Text baseline alignment, Click the […] menu in auto layout properties to open advanced layout settings and check on the text baseline alignment option.

Shortcut: Press B to toggle text baseline alignment on and off once it's enabled.

Strokes in Auto layout

Strokes aren’t counted by default while calculating the size of any object. In the advanced auto layout setting, it can be included or excluded.

Strokes setting- (This GIF is collected from Figma website)

Canvas stacking order

When multiple layers have negative spacing in a stack, the last object (the rightmost) remains on top of the stack by default. It can be changed to First on top.

Tutorial

Figma auto layout playground

Check here

Keyboard shortcut

Conclusion

Auto layout has become one of the most important features of Figma. I have tried to explain everything about auto layout. Any kind of feedback will be appreciated.

Feel free to reach out to me and let me know what you think about this article. Find me on here LinkedIn.

Thanks!

--

--

Hi! I am a Product Designer with a passion for creating user-centered digital experiences. I am specialized in EdTech Industry and I love managing Design System