How to use auto-layout in Figma
Auto Layout is a powerful feature in Figma that allows you to design responsive layouts with ease. With Auto Layout, you can create components that automatically adjust their size and position based on their content and the screen size. In this blog, we’ll explore how to use Auto Layout in Figma.
What is auto-layout?
Auto layout is a feature that will allow you to create frames that respond to content or layout size changes. These dynamic components or frames respond to the size of their child objects, such as a button that grows with the length of its label or a button that now has an icon added and again grows with the length of the component.
Why is auto layout important?
There are two important concepts to understand the importance of this feature: first, we need to know what a layout is; and second, what it means to use a responsive layout.
First, a layout is defined as the arrangement of single or compound items such as images, text, or components on a screen. Layouts use simple or complex components and spacing to encourage consistency across platforms and screen sizes.
Second, a responsive layout allows a frame to change and readapt dynamically based on the screen size, guaranteeing consistency across devices.
Responsive design is crucial to building products for different device sizes from mobile to desktop and tablet in between. Designers have been using layouts and grids to better readapt designs to different screen sizes. If using auto layout, you can place each component in different layouts and they will dynamically adapt to the new content dimension, saving you time readjusting manually each component for each viewport.
How to use Figma’s auto layout
There are three different possibilities to apply auto-layout to a frame or a group, always by selecting the entire frame, group, or just the multiple elements you want to convert:
- Click the right button of the mouse or trackpad and select Add auto layout on the menu.
- Next, click the plus button on the auto layout section in the Properties panel you’ll find on the right of the screen.
- Or, use the keyboard shortcut Shift + A (valid for Mac and Windows).
Once you apply auto-layout, you’ll notice a new frame appear on the left-hand side properties panel. If you double-click on the new frame, you can rename it, and by clicking the right-facing arrow, you can expand the child objects nested inside the parent frame. The child objects will be displayed in the order in which they were placed on the canvas, either from top to bottom or from left to right.
After creating the auto layout, you’ll notice new options on the auto layout panel or menu on the right-hand side. Additionally, a new feature will appear on the Frame menu.
In the upcoming section, we’ll start by going over the basic options of auto layout, then proceed to explore the more advanced features that can enhance the quality of your work.
A new section named horizontal and vertical resizing will show up after creating the auto layout. This section has three options they are:
1. Fixed Height and Width
The fixed height and width option allows you to set a specific size for elements within the auto-layout. This can be useful when you want to ensure that certain elements remain a fixed size regardless of the content they contain. For example, you might want to use fixed height and width for icons or logos.
2. Fill Container
The fill container option allows elements within the auto-layout to expand or contract to fill the available space within the frame. This can be useful when you want to ensure that elements take up all available space, such as when designing a header or footer. You can choose to fill the container horizontally or vertically, or both.
3. Hug Contents
The hug contents option allows elements within the auto-layout to shrink or expand to fit their content. This can be useful when you want to ensure that elements don’t take up more space than necessary. For example, you might want to use hug contents for text boxes or buttons.
To use these options, simply select the element you want to modify within the auto-layout, then navigate to the auto-layout panel on the right-hand side of the screen. From there, you can select the appropriate option and adjust the settings as needed.
In conclusion, the fixed height and width, hug contents, and fill container options in the auto-layout menu provide additional flexibility and responsiveness to your designs. By leveraging these options, designers can create more customized and efficient layouts that adapt to the content they contain.
Navigating the auto-layout menu
There are multiple options in this simplified menu on the right panel. Remember to keep the frame selected to have the panel visible, and I will walk you through all the options from top to bottom and left to right:
The arrows will help you select a vertical or horizontal direction of the parent-children inside the frame
Spacing between the items:
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 the 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.
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. There are nine possible alignment options depending on how you cross and mix the following options:
1. Top left
2. Top center
3. Top right
7. Bottom left
8. Bottom center
9. Bottom right
Now you can control the padding and the spacing between items inside the same frame. You just need to look for the little red handles that appear while hovering the frame and drag them manually to increase or decrease the sizing. If you press one of the handles, a controller will prompt and you can manually change the spacing or padding using your keyboard.
There are a couple of keyboard shortcuts that may be worth it mentioning:
If you hold the Shift key while dragging the handler, the pixels will increase or decrease with the pixel number set previously on the auto layout menu.
If you press Alt while dragging the handler for padding, both sides of the vertical or horizontal realm will increase or decrease equally.
Advanced auto layout menu options
By clicking the three dots of the auto layout menu, an advanced menu will prompt on top. The first thing you’ll notice is a preview section to show the different stages of your selections. Let’s talk about these options:
Spacing mode: There are two options here and packed is the default
- Packed: This keeps the spacing between items as set in the previous menu
- Space between: This option distributes the children objects across the space available on the frame using all the vertical or horizontal space
Strokes: Now you can choose if the strokes are part of the auto layout frame or not. So the stroke surrounds the whole frame and not the children individually, and even the children can have strokes independently as well. This is handy to keep the component clean.
Canvas stacking: While using negative spacing, you now can achieve the stacking effect on your children’s objects. Use this option to change the order of the layers; you can choose between the first or last on top
Text baseline alignment: If you have text on your auto layout frame, select if you want to align it in the center or by its baseline. Only applicable to horizontal alignment.
Is not possible to place an object on top of an auto layout frame, unless you add the object to the frame and you place it wherever you want.
Now the tip holds the spacebar while placing the object on top of the frame and the magic is done, the object is now set on top of it.
To sum up
Figma’s auto layout feature is an incredibly powerful tool that has greatly expanded the capabilities of the platform. The latest release has taken this feature to a whole new level of customization, providing even more flexibility and control for designers.
Despite its impressive capabilities, there is always room for improvement, and it’s likely that Figma will continue to surprise us with more updates and enhancements to the auto layout feature in the future.
Overall, the auto layout feature in Figma is a game-changer for designers who are looking to create complex, responsive layouts with ease. With its intuitive interface and powerful controls, it has become an essential part of many designers’ workflows.
For more information, try checkout this video from figma
I hope you found this information helpful.