Docs
Stacks, grids and auto layout
Turn a frame into a stack or a grid so its contents line up, space themselves and grow with what is inside.
A frame can lay out its own contents. Set it to a Stack and its layers line up in a row or a column with even spacing. Set it to a Grid and they fall into columns. Change the text or add a layer, and everything moves to make room. This is often called auto layout.
Wrap layers in a stack
Select the layers you want to line up.
Press ⇧A. Optic wraps them in a new frame set to a stack that keeps their order and spacing.
Set a frame's layout
Select a frame and open Layout in the panel on the right.
Free: layers stay where you put them.
Stack: layers line up. Choose Down for a column or Across for a row.
Grid: layers fall into columns and rows.
Spacing and alignment
Gap sets the space between layers.
Padding sets the space between the layers and the frame's edge.
Align to Start, Center or End, or Stretch layers to fill the frame.
Between spreads layers out so the first and last touch the edges.
Wrap onto new lines lets a row of tags or cards flow onto the next line when it runs out of room.
Sizing
Width follows content makes a frame hug what is inside it, like a button that grows with its label.
A fixed width keeps the frame the same size whatever goes inside.
Inside a stack, a layer can fill the space that is left.
Build a button
Press T and type the label.
With the text selected, press ⇧A to wrap it in a stack.
Give the new frame a fill, a corner radius and padding, and set its width to follow content.
Change the label. The button grows and shrinks with it.
Questions
What is the difference between a stack and a group?
A group only bundles layers. A stack also lays them out and keeps the spacing as content changes.
Can I nest stacks?
Yes. Most layouts are stacks inside stacks: a page column holding section rows holding cards.
How do I place a badge on top of a card in a stack?
Use constraints on the badge so it sits outside the stack flow. See Constraints and resizing.
Next
Constraints and resizing