Skip to main content
Solved

Swap Component Won't Expand to Fit the Content

  • January 24, 2025
  • 5 replies
  • 105 views

KennLucas

First, so sorry to bring this up again. I know we have all struggled with this for a long time. Gleb seems to be the only master to have really nailed it!

@Gleb ,had this solved pretty well in a previous answer to someone. I have made it work in the past, but this time I am at my wits end!

I tried a lot of different options. I tried making EVERYTHING hug. I tried the fix to fixed size without auto layout. It just is not working for me.

I have a navbar component with a round “seal” logo displayed. However there are times where a different size or shape logo will have to be swapped there. I will not be the one controlling the logo, so vendors could throw in anything really.

Here is the file that I have along with a video showing how I tried to do it.

 

Figma is being weird about uploading the file so you can view and get my Figma file directly here.

 

 

I REALLY do not want to have someone detach the instances in order to customize that, but I am close to scrapping the whole thing.  I am exhausted and frustrated and my deadline was today. I really feel like I have hit the extent of my brain on this one. Any help is appreciated.

Thanks in advance. Really.

 

Best answer by Gleb

You have to have the instance set to hug. What’s inside of it doesn’t matter. From your own experience you can see that the instance set to hug resizes to fit the contents (because that’s what hug does). So the size of the instance becomes defined by the logo (text) inside. By following this logic, you can put a something else inside that would set the size to the desired dimensions.

Solution: put a frame with fixed size inside of the instance. This frame would define the size of the instance that’s hugging it.

View original

5 replies

Gleb
  • Power Member
  • 4706 replies
  • January 27, 2025

Right at the  start you are showing that the “Seal” instance doesn’t have hug contents set on it. It needs to be set to hug.

 

 


KennLucas
  • Author
  • 221 replies
  • January 27, 2025

Thanks @Gleb . I totally see that too but if I change things to hug there it just gets mis-shapen and hugs weirdly. OR, if I try to swap with the ther wider shaped logo it still hugs and gets tiny.

 

I KNOW that is what we are going for, the hug thing...but I am just not getting it there.

I wonder if there is some other way to do that?

In the end all I can see that I am probably going to have to detach all this and give the designers individual bits instead of a good component. I literally worked on this for way too much of yesterday with the same broken results. I tried hugging everything not hugging everything changing things...every combination.

I THINK I can get it to work in the end IF I make the logos and seal always the same size for the swap. But still not getting that done.

 

Thanks Gleb for the feedback. It just is not working over here. 


Gleb
  • Power Member
  • 4706 replies
  • Answer
  • January 27, 2025

You have to have the instance set to hug. What’s inside of it doesn’t matter. From your own experience you can see that the instance set to hug resizes to fit the contents (because that’s what hug does). So the size of the instance becomes defined by the logo (text) inside. By following this logic, you can put a something else inside that would set the size to the desired dimensions.

Solution: put a frame with fixed size inside of the instance. This frame would define the size of the instance that’s hugging it.


KennLucas
  • Author
  • 221 replies
  • January 27, 2025

I did exactly that.

but whether I try including my wider logo in the seal component set OR I try swapping that set for a different wider component, it still displays as the square.

i appreciate your solution as you provided it. I know I have tried that before and I must just not be doing it right.

Thank again for your time Gleb. I will give it a try again tonight paying closer attention to consistency in your suggestion.

🤞


KennLucas
  • Author
  • 221 replies
  • January 27, 2025

You got it @Gleb . Thanks for your patience.

i must have just kept trying to force some imaginary idea.

My problem turned out to be that I was trying to use a general sized seal/logo. Expecting it would stay at size onChange.

My error was, that onChange, it kept the hug size. So the aspect ratio was jacked. If I kept a 200x200 it would be fine. But changing to a 400x200 meant that when I switched back to seal, it was 400x200 and not square and also clipped. 🤬

With your advice, I stopped trying to force it and made my source component set fit the space. Fixed size frame inside of the hug frame.

Works! Thanks again.


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