Skip to main content
Solved

Auto Layout Not Hugging Contents Correctly

  • January 28, 2025
  • 1 reply
  • 92 views

Cé Marina

Hi Figma Community,

I'm having trouble getting an Auto Layout frame to hug its contents correctly. I've set "Hug Contents" for both the horizontal and vertical axes, but the frame doesn't resize to fit the icon inside.

Here's my setup:

  • Auto Layout frame: Contains an icon and text layer.
    The main component has an icon inside that has 2 versions: one that is an square of 68px and there is a particular use of an icon that is double the size. To change between icons I am using a swap instance. 
    Here the screenshot of what I am referring to:
  • Hug Contents: Enabled for both horizontal and vertical axes.
  • Icon constraints: "Left & Right" and "Top & Bottom" (also tried "Scale").

What I want to do, go from icon small to largo and viceversa:

IT WORKS when I set it outside of a component or when I am working inside the same component, look:

However, when I applied to the instance, this happens:
 


So, I've tried the following:

  • Double-checked all settings and constraints. There are no constraints in the icons itself, and when I used constraints on the outside frame, it gets worse. 
  • Removed any unnecessary frames or elements.
  • Restarted Figma.
  • Created a new file and recreated the component. 

However, the issue persists. 

Has anyone else encountered this issue? Any suggestions on how to resolve it? To me it doesn’t make any sense because it already worked before but since Friday is not working properly 😭

 

Thank you so much!

Best answer by Celine_D

Hey ​@Cé Marina ,
Thank you for flagging this!

I see in the backend that the technical team was investigating it with you directly.

For visibility here, I can confirm this is a known feature limitationWhen we do variant/instance swaps of a regular nested instance, we will maintain the size of the original nested instance, even if the swapped in instance is a different size.

As a workaround, we suggest that you add auto-layout for all of the variants of your main component.

Thank you again for flagging this!

View original

1 reply

Celine_D
Figmate
  • Community Support
  • 3381 replies
  • Answer
  • February 24, 2025

Hey ​@Cé Marina ,
Thank you for flagging this!

I see in the backend that the technical team was investigating it with you directly.

For visibility here, I can confirm this is a known feature limitationWhen we do variant/instance swaps of a regular nested instance, we will maintain the size of the original nested instance, even if the swapped in instance is a different size.

As a workaround, we suggest that you add auto-layout for all of the variants of your main component.

Thank you again for flagging this!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings