Lesson 2 of 5 · 6 min

Direction, gap, padding and alignment

The Auto layout section looks like a handful of numbers in the right panel, but each control answers a design question. Once you read it that way, you stop guessing values and start deciding them.

Direction

Direction sets the main axis, the line along which the children of the frame flow. You will use two options almost all the time:

  • Verticaltop to bottom: lists, vertical menus, feeds, forms
  • Horizontalleft to right: rows of buttons, tabs, toolbars

There are also Grid, which places the children in columns and rows you control (dashboards, galleries, bento layouts), and Wrap, a toggle that appears with Horizontal and sends items to a new line when they run out of room. We meet Wrap in lesson 5.

Gap

The gap is the equal space Figma puts between the children. It sets the rhythm of the layout and, together with padding, how dense or airy the interface feels. You can also set it to Auto: Figma then spreads the available space evenly between the elements, which is useful for menus or icon rows that must fill a container.

The pink areas are what Figma shows when you hover the spacing: padding around the edge, gap between the buttons. Change one number and every button moves together.

Padding, not margin

Padding is the space between the content and the edges of the frame, and it pushes the content inward. You can set one value for all sides, one for horizontal and one for vertical, or each side on its own.

The rule of thumb I give in class, and in the book: padding is the inner space, gap is the space between siblings, margin is the outer space around a frame. Figma has no margin field; you get it from the padding or the gap of the parent frame.

Alignment

With Auto layout you no longer align single elements: the nine-dot grid in the panel aligns all the children together inside the frame. In a horizontal frame it decides top, centre or bottom; in a vertical frame left, centre or right. A small shortcut: double click the grid to switch the Auto gap on or off.

If alignment seems to do nothing, check the size of the frame. When the frame hugs its content there is no extra space to move things into, so you only see the effect when the frame is bigger than its children.

Adding, removing and reordering

Inside an Auto layout frame you don’t place things by hand any more. Drag an element in and a blue line shows where it will land; drag it out to take it out of the stack; press ⌘ Cmd + D (Ctrl + D on Windows) to duplicate it right next to the original; use the arrow keys to move a selected child up, down, left or right in the order. The spacing fixes itself every time.

Try it: a button group

  1. Select the Button / Primary / Default frame from lesson 1 and press ⇧ Shift + A to wrap it in a new Auto layout frame.
  2. Rename the new frame Button Group (⌘ Cmd + R), set the direction to Vertical and the gap to 16.
  3. Select the button and duplicate it with ⌘ Cmd + D. Rename the copy Button / Secondary / Default.
  4. Change its text to Sign Up and give it a different fill. The button resizes on its own.
  5. Select the Sign Up button and press the up arrow: it moves above Login. Press the down arrow to put it back.
  6. Set the Button Group width to 361, then try the alignment grid: left, centre, right. Now you can see what it does.

Remember

  • Direction picks the axis: Vertical, Horizontal, or Grid; Wrap is a toggle of Horizontal.
  • Padding is inside, gap is between siblings, margin is outside.
  • Alignment moves all the children together, and needs a frame larger than its content.
  • Drag in, drag out, ⌘ D to duplicate, arrow keys to reorder.