Tips & Tricks for Auto Layout in Figma
What is auto layout?
Auto layout is a property that allows you to create dynamic frames that automatically adjust items horizontally or vertically. When the property is applied the frame layer becomes an auto layout frame which has it’s own corner radius, fill, and stroke — no additional layers needed.
What to use auto layout for?
- Buttons that adjust to the length of your text
- Repeatable lists
- Add to existing components
Basics— Adding Auto Layout
Once a frame is selected, you then can go to the properties panel and add auto layout (displays under the constraints property). Or you can use the keyboard shortcut, Shift A.
When auto layout is added, you will notice that the frame icon changes to the two rectangles indicating that auto layout is applied to the frame.
Adding Auto Layout to Buttons
You can add auto layout to a button (in a frame) to automatically adjust for text length while maintaining your desired value for padding (horizontal and vertical).
With frames, you will no longer need to create a background layer for your button’s fill color. If you add auto layout and have a fill color layer, the layer is removed, then the fill color is automatically contained in your frame’s properties.
Auto layout is useful for nested frames, that is when you have child frames inside of a parent frame.
In the example below, the parent frame is “Button Set” which contains the three child frames (each of the buttons). On the parent frame, you can add auto layout to space out each of the buttons which is independent from the child frames. The child frames retain their own auto layout values.
An auto layout frame will only allow direct drag-n-drop of items that are smaller in size than the frame size. For items larger than the frame size, you can force it to get inside by dragging the item, then holding the ⌘ key. By forcing a larger sized item into your frame, this will automatically adjust the size of the button to fit the larger item.