Skip to main content
Cody_Porter
New Member
January 22, 2021

LAUNCHED: Min and Max Width for Auto Layout

  • January 22, 2021
  • 95 replies
  • 65552 views

I would like to add a max-width to a text box while using auto layout to keep the word count per line at a reasonable minimum.

Currently, I have the text element set to “Fill Container” which makes the text respond very nicely to the screen size. But because it is set to “Fill Container”, the text spans the entire width of the element which makes the text lines more difficult for users to read quickly.

If a max-width was set, the component should respond until it reaches the max-width, which would help keep the line length down.

I also feel like there are many other circumstances where max and min-width would be extremely helpful

Anyone else having this issue? Or does anyone have a great fix/hack to get around it?

Looking forward to seeing what you have to say.

Cheers,

95 replies

Gleb
Power Member
January 23, 2021

There is no workaround for setting max-width, this is impossible. But for min-width, you can put an invisible line (set opacity to 0%, don’t hide the object itself) inside of the auto-layout frame. This line will prevent the frame from shrinking too much when the text is smaller than the line. There is an example in my file Auto Layout Tips & Hacks:

Figma
Vitalii_Sologub
New Participant
January 23, 2021

You can also mimic the max-width for components and their elements. Unfortunately, it’s not an automated process — you should manually switch some preferences but it still saves some time.
Please check this file.

Mr.Biscuit
New Participant
January 23, 2021

Awesome solo_cube!

ChristianBergstrom
January 25, 2021

Adding multipliers to fill container would also be helpful, and would correspond well with flex box, so you can set 2 or 3 to continuously fill but with 1 at 2 or 3x the size of another.

mattaningram
New Participant
January 26, 2021

It would get a bit confusing since that’s not exactly how flex works. The flex-grow setting determines how remaining available space is distributed, not how overall space is distributed. So the contents of one of the flex items can make it so a flex-grow: 2 item is not actually twice as big as a flex-grow: 1 item.

What we need is actual CSS in Figma, not these approximations of it that continue to confuse my developers in hand-off.

Pavels_Amosovs
February 1, 2021

This would be very useful. Another use case would be localization: in some languages button labels may become much shorter when compared to English for example. In this case I’d want to set a min-width for the button component so that buttons don’t shrink too much. This is just one simple but rather common example.

Travis
New Member
February 5, 2021

Having access to min/max settings would be so nice. Many components in our design system have this in documentation, but not in the Figma library, and we can’t rely on people reading every last detail in the docs (unfortunately). Having this built in would also be huge for showing responsive behaviors across devices!

Vyacheslav_Dubovitsky
February 7, 2021

+1 here. The last thing that actually keeps me using Sketch+Anima is lack of min/max width/height constraints.

Josiah
February 10, 2021

+1 here. I’m working on a table concept, and I specifically need to be able to set a component to fill-container and “min-width.”

Tiffany_Lieu
February 22, 2021
  1. Right now if we want to set a min width and max width for a component we have to make 2 different variants and its kinda silly that you have to keep swapping the variants to make either use fixed width (for min width) and fill container for expanding the width.

  2. Does anyone experience this? Or is there a plugin where I can make this happen?