{"id":"l-fig-2-1","courseId":"figma-ui-design","lang":"en","kind":"lesson","summary":"Turn static frames into auto layout frames that stack their children with a set flow, gap, padding and alignment, and nest them to build Steady’s habit row and list.","html":"<p>In the last lesson you built a habit row by placing an icon, a name, a streak and a check button by hand. Now change “Read” to “Read 20 pages before bed”. The name runs into the check button. Add a second line and the streak overlaps the next row. Every content change means nudging layers, and in a real app content changes every day.</p>\n<p>Auto layout is Figma’s answer: you tell a frame <em>how</em> to arrange its children, and it positions them for you, every time anything changes.</p>\n<h2 id=\"sec-1\" tabindex=\"-1\">The three settings that matter most</h2>\n<p>Select the habit row’s layers and press <code dir=\"ltr\">Shift+A</code>, or click <strong>Add auto layout</strong> in the right sidebar. Figma wraps them in an auto layout frame and makes a first guess at the settings. Three of them do most of the work.</p>\n<p><strong>Flow</strong> is the direction children are placed in. At the time of writing, Figma offers <strong>Vertical</strong>, <strong>Horizontal</strong> and <strong>Grid</strong>. Vertical stacks children top to bottom, like the habit list. Horizontal lines them up side by side, like the inside of one row. Grid places children in rows and columns, which suits a two-dimensional layout such as the icon picker in the New habit sheet.</p>\n<p><strong>Gap</strong> is the space <em>between</em> children. It is one number for the whole frame, so every child is the same distance from the next. You can also choose automatic spacing, which at the time of writing offers Between, Around and Evenly, to distribute leftover space instead of fixing it. Use a fixed number almost always; automatic spacing is for cases like a tab bar where items spread across the width.</p>\n<p><strong>Padding</strong> is the space between the children and the frame’s own edges. You can set it on all sides at once, horizontal and vertical separately, or per side.</p>\n<h2 id=\"sec-2\" tabindex=\"-1\">Building the habit row</h2>\n<p>Here is the row as nested auto layout frames. Each frame has one job.</p>\n<div class=\"code-block\" dir=\"ltr\" data-lang=\"text\" data-index=\"0\"><div class=\"code-head\"><span class=\"code-title\">Text</span><span class=\"code-actions\"><button type=\"button\" class=\"code-btn\" data-action=\"copy\" aria-label=\"Copy code\"><svg class=\"icon \" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"/></svg><span>Copy</span></button></span></div><pre class=\"shiki\" tabindex=\"0\"><code>Habit row        Horizontal · gap 12 · padding 12 top/bottom, 16 left/right · align center\n├─ Icon          32 × 32\n├─ Text stack    Vertical · gap 4\n│  ├─ Habit name   Headline 17/24\n│  └─ Streak       Caption 13/16\n└─ Check button  32 × 32 circle</code></pre></div>\n<p>The text stack is its own vertical frame because the name and streak are a group (Lesson 1.2: small gap inside, bigger gap outside). The row is horizontal because icon, text and button sit side by side. The 4 px inside the text stack is smaller than the 12 px between row elements, which is smaller than the space between rows. Proximity is now built into the structure, not maintained by hand.</p>\n<figure class=\"diagram\"><svg class=\"diagram-svg\" focusable=\"false\" viewBox=\"0 0 680 220\" role=\"img\" aria-labelledby=\"l-fig-2-1-t1\"><defs><marker id=\"arrow-l-fig-2-1-1\" viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0 L10 5 L0 10 z\" class=\"d-arrowhead\"/></marker></defs>\n  <title id=\"l-fig-2-1-t1\">A habit row frame with 16 pixel left and right padding and 12 pixel top and bottom padding. Inside, an icon, a text stack and a check button are separated by 12 pixel gaps. The text stack holds the name and streak with a 4 pixel gap.</title>\n  <rect class=\"d-box\" x=\"20\" y=\"40\" width=\"640\" height=\"120\" rx=\"14\"/>\n  <rect class=\"d-box-warn\" x=\"20\" y=\"40\" width=\"40\" height=\"120\" rx=\"0\"/>\n  <rect class=\"d-box-warn\" x=\"620\" y=\"40\" width=\"40\" height=\"120\" rx=\"0\"/>\n  <text class=\"d-label-muted\" x=\"40\" y=\"182\" text-anchor=\"middle\">16</text>\n  <text class=\"d-label-muted\" x=\"640\" y=\"182\" text-anchor=\"middle\">16</text>\n  <rect class=\"d-box-primary\" x=\"60\" y=\"70\" width=\"60\" height=\"60\" rx=\"10\"/>\n  <text class=\"d-label\" x=\"90\" y=\"105\" text-anchor=\"middle\">Icon</text>\n  <rect class=\"d-box-success\" x=\"120\" y=\"70\" width=\"30\" height=\"60\" rx=\"0\"/>\n  <text class=\"d-label-muted\" x=\"135\" y=\"150\" text-anchor=\"middle\">12</text>\n  <rect class=\"d-box-accent\" x=\"150\" y=\"62\" width=\"380\" height=\"76\" rx=\"8\"/>\n  <text class=\"d-label-strong\" x=\"166\" y=\"90\">Read 20 pages</text>\n  <text class=\"d-label-muted\" x=\"166\" y=\"124\">12-day streak</text>\n  <text class=\"d-label-muted\" x=\"520\" y=\"108\" text-anchor=\"end\">gap 4</text>\n  <rect class=\"d-box-success\" x=\"530\" y=\"70\" width=\"30\" height=\"60\" rx=\"0\"/>\n  <text class=\"d-label-muted\" x=\"545\" y=\"150\" text-anchor=\"middle\">12</text>\n  <circle class=\"d-dot\" cx=\"590\" cy=\"100\" r=\"30\"/>\n  <text class=\"d-label-muted\" x=\"340\" y=\"28\" text-anchor=\"middle\">padding 12 top</text>\n  <text class=\"d-label-muted\" x=\"340\" y=\"206\" text-anchor=\"middle\">padding 12 bottom</text>\n</svg><figcaption>Anatomy of the habit row: padding on the outside, gap between children</figcaption></figure>\n<p>Now stack rows. Select all the rows and press <code dir=\"ltr\">Shift+A</code> again: Figma wraps them in a vertical frame, the <code dir=\"ltr\">Habit list</code>, with an 8 px gap. Wrap the progress block and list in a vertical frame with a 24 px gap, then wrap the header and that frame in one more vertical frame with 20 px horizontal padding and a 32 px gap. Two levels of gap give you the stepped spacing from Lesson 1.2, and the whole Today screen is now structured by auto layout. Change any name, add a sixth habit or delete one, and everything below moves to make room.</p>\n<h2 id=\"sec-3\" tabindex=\"-1\">Alignment</h2>\n<p>Each auto layout frame also controls how its children line up across the flow. In a horizontal row, you choose whether children sit at the top, center or bottom of the row; in a vertical stack, whether they hug the left, center or right. The habit row uses center alignment so the icon and check button line up with the middle of the text, whether the name is one line or two.</p>\n<p>For rows of text with different sizes, horizontal frames also offer baseline alignment at the time of writing, which lines up the bottoms of the letters instead of the boxes. It is ideal for a label and a value side by side, such as “Streak” and “12 days”.</p>\n<aside class=\"callout callout-mistake\" role=\"note\"><p class=\"callout-title\"><svg class=\"icon \" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\"/><path d=\"M12 9v4\"/><path d=\"M12 17h.01\"/></svg><span><span class=\"callout-kind\">Common mistake</span><span class=\"callout-sep\" aria-hidden=\"true\"> · </span>Spacing on the wrong layer</span></p>\n<p>When something is too close to its neighbour, beginners add an empty rectangle as a spacer, or wrap a child in an extra frame just to give it padding. Both hide spacing where no one looks for it. Ask instead: is this the space <em>between</em> siblings (the parent’s gap) or the space <em>inside</em> a container (that container’s padding)? Change that one number.</p>\n</aside>\n<aside class=\"callout callout-tip\" role=\"note\"><p class=\"callout-title\"><svg class=\"icon \" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5\"/><path d=\"M9 18h6\"/><path d=\"M10 22h4\"/></svg><span><span class=\"callout-kind\">Tip</span><span class=\"callout-sep\" aria-hidden=\"true\"> · </span>Read the structure, not the pixels</span></p>\n<p>When an auto layout frame looks wrong, select the parent first and read its flow, gap, padding and alignment in the right sidebar. Nine times out of ten the fix is one setting on the parent, not anything on the child you are staring at.</p>\n</aside>\n<p>You have the habit row stacking correctly. What it does not do yet is stretch to fill the screen width or let long names wrap at the right place. That is resizing, the subject of the next lesson.</p>\n","toc":[{"id":"sec-1","text":"The three settings that matter most","level":2},{"id":"sec-2","text":"Building the habit row","level":2},{"id":"sec-3","text":"Alignment","level":2}],"takeaways":["Auto layout makes a frame arrange its children for you, so changing content never means nudging layers by hand again.","Flow sets the direction (vertical, horizontal or grid), gap sets the space between children, and padding sets the space between the children and the frame’s edges.","Spacing belongs to the parent frame, never to spacer rectangles or offsets on the children.","Real components are nested auto layout frames, such as a horizontal row that contains a vertical text stack.","Most auto layout bugs come from settings on the wrong level of nesting, so check the parent before you blame the child."],"further":[{"title":"Guide to auto layout","url":"https://help.figma.com/hc/en-us/articles/360040451373-Guide-to-auto-layout"},{"title":"Use the horizontal and vertical flows in auto layout","url":"https://help.figma.com/hc/en-us/articles/31289464393751-Use-the-horizontal-and-vertical-flows-in-auto-layout"}],"quiz":[{"q":"<p>You change a habit name from “Run” to “Run 5 km before work” inside an auto layout habit row. What happens to the check button on the right?</p>","options":[{"text":"It overlaps the longer name until you move it.","why":"That is what happens in a frame without auto layout. Auto layout recalculates positions as content changes."},{"text":"It stays exactly where it was, because buttons are fixed.","why":"Children in auto layout have no fixed x and y. Their position comes from the flow, gap and their siblings."},{"text":"It is pushed along the flow, or the name wraps, depending on how the row and text are set to resize.","why":"Correct. The row re-flows and the button keeps its gap from the text. Whether the name wraps or the row grows is a resizing choice (next lesson)."},{"text":"Figma shows a warning that the content no longer fits.","why":"Figma has no such warning. Auto layout adapts the layout instead."}],"answer":2},{"q":"<p>The text stack inside a habit row has 4 px gap, and the row has 16 px left padding. A designer adds a 16 px empty rectangle before the icon to push it right. What is wrong?</p>","options":[{"text":"Nothing, because the result looks the same.","why":"It looks the same until someone changes the padding or swaps the icon. Hidden spacers make the spacing impossible to reason about or hand off."},{"text":"Spacing should come from the parent’s padding and gap, not from invisible layers.","why":"Correct. If the icon needs more room, change the row’s padding. Spacer layers show up as mystery boxes in Dev Mode."},{"text":"Rectangles cannot be children of auto layout frames.","why":"They can. The problem is using one as a spacer, not whether it is allowed."},{"text":"The rectangle should be 8 px so the total stays on the 8-point grid.","why":"Changing the size keeps the hidden-spacer problem. Spacing values belong in padding and gap."}],"answer":1},{"q":"<p>Which structure best describes Steady’s habit row?</p>","options":[{"text":"A vertical auto layout frame containing icon, name, streak and check button.","why":"A single vertical stack would put the check button below the streak instead of beside the text."},{"text":"A group containing four layers placed by hand.","why":"Groups cannot use auto layout, so every content change means repositioning by hand."},{"text":"A grid auto layout with one column per element.","why":"Grid suits two-dimensional layouts like the icon picker, not a single row with a nested text stack."},{"text":"A horizontal auto layout frame containing the icon, a vertical text stack and the check button.","why":"Correct. The row flows horizontally, and the name and streak stack vertically inside their own frame."}],"answer":3},{"q":"<p>Inside a horizontal habit row, the icon sits at the top while the text and check button are centered. Where do you fix it?</p>","options":[{"text":"On the row frame, by setting its alignment so children are centered vertically.","why":"Correct. Alignment of children is a property of the parent auto layout frame."},{"text":"On the icon, by nudging it down 6 px.","why":"You cannot position a child by hand in auto layout without taking it out of the flow. Alignment lives on the parent."},{"text":"On the page, by adding a layout guide.","why":"Layout guides help you align frames, but they do not change auto layout alignment."}],"answer":0}],"exercise":{"kind":"fill","language":"text","template":"Chip (auto layout)\n  Flow:                  {{0}}\n  Gap between items:     {{1}}\n  Padding left/right:    {{2}}\n  Padding top/bottom:    {{3}}\n  Align children:        {{4}}\n\nFrequency chips (auto layout)\n  Flow:                  {{5}}\n  Gap between items:     {{6}}","blanks":[{"answers":["Horizontal"]},{"answers":["4","4px","4 px"]},{"answers":["12","12px","12 px"]},{"answers":["6","6px","6 px"]},{"answers":["Center","Centre","Middle","Center vertically","Centered","Centred","Vertical center","Left center","Center left"]},{"answers":["Horizontal"]},{"answers":["8","8px","8 px"]}],"title":"Set up the frequency chips","prompt":"<p>The New habit sheet has a row of frequency chips: <strong>Daily</strong>, <strong>Weekdays</strong>, <strong>Weekends</strong>, <strong>Custom</strong>. Each chip is a 16 × 16 icon followed by its label. From the developer’s redline:</p>\n<ul>\n<li>In each chip, the icon and label sit <strong>4 px</strong> apart and are centered on each other vertically.</li>\n<li>The chip’s content sits <strong>12 px</strong> from its left and right edges and <strong>6 px</strong> from its top and bottom edges.</li>\n<li>The chips sit side by side, <strong>8 px</strong> apart.</li>\n</ul>\n<p>Fill in the auto layout settings for one chip and for the row that holds all four. Use the names Figma shows (Vertical, Horizontal or Grid for flow; Top, Center or Bottom for alignment) and numbers in px.</p>\n","hints":["Two frames are involved: each chip, and the row that contains the chips. Which one owns the 8 px?","Space between children is gap; space between the children and the frame edge is padding.","Chip: Horizontal, gap 4, padding 12 and 6, centered. Row: Horizontal, gap 8."],"explanation":"<p>Each chip is a <strong>Horizontal</strong> auto layout frame because the icon and label sit side by side. The 4 px between them is the chip’s <strong>gap</strong>; the 12 px and 6 px around them are its <strong>padding</strong> (6 is off the spacing scale on purpose: with a 20 px label line it gives the chip an even 32 px height, the kind of written reason Lesson 2.3 asks for); and centering is the chip’s alignment, set on the parent, not by nudging the icon. The 8 px between chips belongs to the parent row, another <strong>Horizontal</strong> frame with an <strong>8</strong> px gap. Putting each value on the frame that owns it means a developer can read it straight from Dev Mode, and a longer label like “Weekends” grows its chip without breaking the row.</p>\n","checkLabels":{}},"words":785,"readMinutes":4}