Skip to main content
Question

Instant swap property distorts nested component aspect ratio when the two instances aren't the same size


Hi all! I searched Figma forums all over for an answer but couldn’t find one. The issue I’m having is with icons becoming distorted when using instance swap in a nested component. Here’s the context:

I am working on a design system that utilizes 4 different icon sizes that are all square (14x14px, 24x24px, and so on).

We are using Font Awesome icons, and the vectors of these icons vary in size, meaning that two icons with the same height may vary in width.

My ideal vision is that we make the icon frame sizes components, then place the icons (also components) inside of the square frame and set them to scale. This is so that if we ever decide to do a global icon resize (say we decide 14x14 is to small and want to move to 16x16) that we can do that on the master component level and avoid manually updating all the affected components.

However, the issue I am having is that when I swap one icon for another in a child component, rather than maintaining its proportions, it takes on the size of the icon it is replacing. this only happens on my nested component icons.

I want to know if there is a solution other than having to put all my icons in perfectly square frames so to fit the icon frame standards. I tried using the auto-layout trick, but because the master component icons are sized at 36px height, they aren’t scaling down to our smaller icon frame sizes (14px and 24px). trying to also avoid creating 3 different size variants for every icon if possible.

I hope that makes sense. heres some screenshots for context.

10 replies

tank666
  • 4863 replies
  • January 22, 2024

Auto layout should solve your problem. I don’t know what the structure of your icon components is, but you might need to add an additional wrapper.

https://forum.figma.com/t/issue-keep-the-scaling-of-a-nested-component-when-swapping-it/1009/23


Hi there! thanks so much for taking the time to respond.

In your file, notice how all your icons are the same size? they are all 16x16px. my icons all have the same height, but varying widths. so when I swap instances, it distorts the width of the icon to match the one in the parent component. I added another screenshot that also includes my button structure.


specifically wondering if there is another solution other than wrapping all the icons in the same size frame. We have a ton so it’ll take a long time so wanted to ask the community before I did it.


mo_hamwi
  • New Participant
  • 49 replies
  • January 23, 2024

you can do that if the button is not a component

See this example


Check the Structure
Figma – 23 Jan 24


tank666
  • 4863 replies
  • January 23, 2024

Thanks for the clarifications. That is, all your icon component containers are different sizes. So, I think you need to bring the containers down to the same size (eg 14x14) and I’m afraid that’s the only way to solve your problem.

You can use plugins for faster work. Try searching for suitable plugins here: Figma Community.


Janina2
  • 1 reply
  • May 27, 2024

Hi! Sorry I’m late to the conversation. You can also select the icon component and add autolayout (Shift-A). This worked for me. I had exactly the same issue as you did and saw this thread, and saw this simple solution on youtube 🙂


Jess_Bellatti

Hey Figma Community! Has there been an update regarding this topic?

I am having the same issue where I want to be able to swap out different logos inside of a component and am not able to find a solution in which the logos maintain the height of the original while the width is responsive to maintain the aspect ratio.


Herza
  • New Member
  • 1 reply
  • January 21, 2025

I am encountering same issue. The child instance should be allowed to keep its aspect ratio. This is crutial (please)!


Bruno_Biagioni_Neto

I have the same problem. This occurs when you use too many nested elements. The bug does not occur at the first or second level, but from the third level onwards it does.

 


jo1
  • New Participant
  • 6 replies
  • February 17, 2025

I would love this resolved, working with logos that have different aspect ratios. There should be some switch or something, so you can maintain the aspect ratio along the longest length.


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