Skip to main content
Bethany_McBride_174
New Member
Nov 12, 2024 12:16 AM UTC

Hug until container is too small

I would like an option to hug content until the container it is in is too small. For instance, I am making a tab bar where the tabs are set to fill so they adjust with screen sizes. The title on each has an info icon to the right. The text has to be set to hug for the icon to stay right next to the text. However, that means if the text is long, when the tabs shrink the text extends out rather than wrapping.

I would like the option to set the hugged text to wrap when it extends past the parent container without having to manually change it a each breakpoint.

    17 replies

    Adam_Rodriguez
    New Member
    Nov 13, 2024 4:14 PM UTC

    Have you tried max and min width sizes? This isn’t always the best but it does get the idea across in some cases.

    UsabilityJeff
    New Participant
    Apr 4, 2025 4:56 PM UTC

    Ugh, I currently have a requirement for this too!

    In my case, I am making labels for the Y-axis of a chart. It would be easy except that on hover there is fill color, so the frame of the text needs to “hug” the text.

    Some labels can be quite long though, so they need to wrap to fit in the “label gutter” container. That is, the frame magically needs to turn to “fill” when the “label gutter” container responsively narrows.

    My work around is to have two variations of the component, one for short labels that don’t need to wrap, and one for long ones that do, But this only partially works for a defined range of container widths, where all the short labels never need to wrap, and all the long labels never need to hug.

    Francesco_Fagioli2
    New Member
    Jul 31, 2025 6:31 AM UTC

    I'm building a responsive alert banner and trying to achieve a behavior similar to fit-content in CSS. Here's what I need:

    • The banner container stretches to 100% width,

    • Inside, there's a button and a text label,

    • The text should stay on one line and hug its content until it reaches the limit of the container,

    • Once it can't fit anymore, it should wrap onto multiple lines (essentially behave like fill).

    Think of it as:
    "hug content until there's no space left → then behave like fill".

    This should happen dynamically, depending on the container width,

    so no fixed max width.

    Is there any way to simulate this behavior in Figma, maybe with some clever auto layout nesting or constraints?

    Trying to avoid duplicating the component with two variants (hug and fill).

    Thanks in advance for any ideas or workarounds!

    Bethany_McBride_174
    New Member
    Aug 11, 2025 5:44 PM UTC

    Have you tried max and min width sizes? This isn’t always the best but it does get the idea across in some cases.

     

    That is a good suggestion, but as you said not the best.

    The problem with min-max widths as a workaround, is that it limits the reusability of the component. I could set the max width to the width of the current text, but then if we need to change the copy or use this in another area with different labels, then we would need the max width to change for each use case. 

     

    Harry-Pekka_Laakso
    New Member
    Sep 3, 2025 6:49 AM UTC

    It would be nice to have more CSS-like options for designing auto-layout content. Making min and max values for each breakpoint just feels wrong but currently there’s no other way 😥

    Mohsen_UX
    New Member
    Sep 26, 2025 2:30 PM UTC

    Hey there! Have you found any solution for that issue? 

    Dan2
    New Participant
    Nov 5, 2025 12:15 AM UTC

    Came here looking for a solution to this as well

    Martin Rasmussen
    New Member
    Jan 16, 2026 8:52 AM UTC

    Same here. Missing an ‘always respect parent boundary’-option of some sort.

    Stevie3
    New Member
    Jan 22, 2026 7:56 AM UTC

    something like this? 

    Narelle
    New Participant
    Jan 27, 2026 6:20 AM UTC

    This function is so needed to be able to effectively communicate what is required, and seems like basic principles that figma should support. There is max-width function but it is a fixed value, so does not support building a responsive component. Potentially allowing percentage values in max-width could achieve this i.e. 100%, so it response to the parent container size. However, max width would also be required to restrict to an absolute max - i.e. to ensure paragraphs don’t exceed a width suitable for readability when the parent container is even wider.