Skip to main content
Solved

Make a component whose width will adjust automatically depending on the text width


nurisa_rahma_shantika

i want to make a component whose width will adjust automatically depending on the text width, but there’s an icon beside the adjustable text, and i want the icon will also automatically adjust depending on the text width. may i get a help? thank you before

Best answer by pavelsoyfer

Hi there. I think I get you’re trying to do here — may I suggest you apply Hug contents to both the Account Name frame and the text inside, but also apply a max-width to the Account Name, so that when the text reaches the set size it’ll start wrapping inside? There may still be an extra gap between text and the icon, but it’s pretty much the best you can do I believe. I’m uploading a screenshot, I hope I understood your idea right.

View original

5 replies

Avokadomos
  • New Participant
  • 376 replies
  • March 27, 2024

Your Account Name layer is already an auto layout, but have you set the width of it to hug contents?


nurisa_rahma_shantika


I tried it but it looks like this. i want to set the Account Name to fixed width so that the content inside does not exceed the Account Name width.


pavelsoyfer

Hi there. I think I get you’re trying to do here — may I suggest you apply Hug contents to both the Account Name frame and the text inside, but also apply a max-width to the Account Name, so that when the text reaches the set size it’ll start wrapping inside? There may still be an extra gap between text and the icon, but it’s pretty much the best you can do I believe. I’m uploading a screenshot, I hope I understood your idea right.


Avokadomos
  • New Participant
  • 376 replies
  • March 29, 2024

You can also truncate the text if you don’t want it to wrap.


nurisa_rahma_shantika

thank you it works!


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