Docs
Constraints and resizing
Constraints decide what a layer does when its frame changes size: stay put, stretch, or keep to an edge.
Constraints tell a layer how to behave when the frame around it is resized. They matter most for frames that change width, like a page you check in Run or a breakpoint for phones.
Set constraints
Select a layer that sits freely inside a frame.
Open Constraints in the panel on the right.
Pick a Horizontal pin and a Vertical pin, or use the quick buttons: Pin left, Pin right, Pin top, Pin bottom, Centre horizontally and Centre vertically.
What each pin does
Left, Right, Top or Bottom keep the layer a fixed distance from that edge.
Left and right stretches the layer as the frame gets wider. Top and bottom does the same for height.
Centre keeps it in the middle.
Scale grows and shrinks the layer in proportion to the frame.
Sizing
Under sizing, choose Fixed to keep a set size, Fill to take the space available, or Hug to wrap the content. Add Min W, Max W, Min H and Max H to stop a layer getting too small or too large.
Check it
Drag the frame's edge, or open the design in Run and drag the width. Layers move or stretch as you set them.
Constraints or stacks?
Use a stack for content that flows: lists, rows of cards, text that grows.
Use constraints for things pinned in place: a close button in a corner, a background that fills a frame, a badge over an image.
Questions
My layer stretched when I did not want it to.
It is probably set to Left and right. Switch it to Left or Centre.
Do constraints work inside a stack?
Layers in a stack follow the stack. Constraints apply to layers that sit freely in a frame.
Do constraints carry into HTML exports?
Yes. The exported HTML and CSS follow the same rules.
Next
Components and variants