As a Senior Product Designer, I’ve realized that the difference between a static design and a scalable system often comes down to one thing: Auto Layout. If you want to build responsive products that developers actually love, you have to move past "moving pixels" and start defining the relationship between elements.

Understanding Fixed, Hug, and Fill is the foundation of modern UI engineering. Here is exactly how to use them:

Fixed Width: Precise Control

A Fixed element stays the same size regardless of its parent container or the content inside it. Whether your parent container is 400px or 800px wide, a fixed 300px element will never budge.

  • Best for: Specific UI components like buttons, icons, and fixed sidebars where you need absolute control.

Hug Contents: The "Shrink-Wrap" Effect

When an element is set to Hug, it shrinks to fit its content exactly. The content determines the size. If you change the text inside a button, the button adjusts automatically to maintain the padding.

  • Best for: Dynamic components like pills, tags, and auto-width labels.+2

Fill Container: True Responsiveness

The Fill setting allows an element to expand and match the parent's available space. No matter how much the parent container grows, the element will always fill 100% of the allowed area.

  • Best for: Responsive elements like full-width inputs, cards, and large containers.

The Senior Perspective

Auto Layout isn't just a shortcut; it’s a communication tool. By mastering these three behaviors, you ensure that your design intent is maintained from the smallest mobile screen to the largest desktop monitor.