31. Apply Min and Max Width to Components

Skills: Set min-width on a card or button; Set max-width to prevent over-stretching; Combine with Fill container for responsive behaviour; Test with different parent widths

Min and max width prevent components from becoming too small or too large when the parent resizes. They're essential for responsive buttons, cards, and input fields.

31. Apply Min and Max Width to Components
Figure: A button using Fill width with min-width set to prevent it from shrinking too small when the container is narrow.

Step-by-step

  1. Create a button component: a rounded rectangle with text, Fill for width so it stretches with the container
  2. Place the button inside a narrow frame (200 wide) — the button fills the full width
  3. In the Design panel, scroll down to Constraints & Resizing section
  4. Set Min width to 120px — the button won't shrink below this
  5. Now place the button in a very wide frame (600 wide) — the button stretches to 600px (probably too wide)
  6. Set Max width to 320px — the button won't grow beyond this
  7. Test: resize the parent frame. The button stays between 120px and 320px
  8. Apply min-width to a card component to prevent it from collapsing too small
  9. Apply max-width to a text body to prevent overly long line lengths
  10. Combine min-width + Fill for adaptive components that have constraints

Pro tip

Min/max width only works on auto layout items or frames. A regular rectangle with fixed dimensions won't honour min/max width. The component must be set to Fill or have auto layout enabled.