Layout & Design

Min and Max Sizing in Framer (Fundamentals Lesson 11)

Min and Max Sizing in Framer (Fundamentals Lesson 11)

Min and Max Sizing in Framer (Fundamentals Lesson 11)

Joseph

·

8:26

·

34K views

·

About this lesson

When we use flexible sizing modes like fill or relative, we run the risk of things being stretched or squashed to such a degree that things get a bit… well… ugly.

This is where Min and Max values come in — allowing us to enforce some limits to how big or small things can get — to keep things fluid… but contained.

Let’s spend some time getting more familiar with the mechanics of min and max and look at some examples of when it saves the day.

https://www.youtube.com/watch?v=NJKKqYbYeVE&t=0s Intro

https://www.youtube.com/watch?v=NJKKqYbYeVE&t=11s Why min and max values matter

https://www.youtube.com/watch?v=NJKKqYbYeVE&t=30s Understanding min and max sizing

https://www.youtube.com/watch?v=NJKKqYbYeVE&t=96s Example: min width for responsive cards

https://www.youtube.com/watch?v=NJKKqYbYeVE&t=189s Using max width to prevent overly wide layouts

https://www.youtube.com/watch?v=NJKKqYbYeVE&t=291s Min height for viewport-sized sections

https://www.youtube.com/watch?v=NJKKqYbYeVE&t=386s Max height for text boxes

https://www.youtube.com/watch?v=NJKKqYbYeVE&t=478s Wrap up

🌞 Start for free: https://framer.link/yt

📚 Learn more at: https://framer.link/yt-academy

💎 Join the Community: https://framer.link/yt-community

🎉 Follow on X: https://framer.link/yt-x

0:00when we use flexible sizing modes like0:01fill or relative we run the risk of0:04things being stretched or squashed to0:06such a degree that things get a bit well0:10ugly this is where Min and Max values0:13come in allowing us to enforce some0:15limits to how big or small things can0:17get to keep things fluid but contained0:21let's spend some time getting more0:22familiar with the mechanics of Min and0:23Max and look at some examples of when it0:25saves the day0:27[Music]0:30in the simplest terms Min for minimum0:33means don't get smaller than and Max for0:36maximum means don't get bigger than0:39setting a minimum size props up the0:41inside of our frame making sure it won't0:43shrink below a certain point this is0:45useful when we want an element to0:47maintain legibility or structure even as0:49the screen gets smaller preventing0:51things from being completely squashed0:54setting a maximum size on the other hand0:56boxes in the outside of our frame0:58ensuring that it won't continue to1:00expand Beyond a certain point keeping1:02the layout tidy and contained without1:05getting stretched into Oblivion by1:07default the actual Min and Max height1:09and width Fields don't show up on the1:11properties panel until we click to add1:12them if and when we need them we can set1:15these fields to either fix sizing using1:18exact pixels or relative sizing using1:21percentages giving us some flexibility1:23depending on our needs a good rule of1:25thumb is that if a dimension is flexible1:27then the Min or Max would be fixed1:30and if the dimension is fixed the Min or1:32Max would be flexible which I'll show1:34you an example of here in a bit let's1:37start with an example of when Min and1:39Max WID might come in handy on this page1:42we have a feature section with a set of1:44cards and a horizontal stack that wraps1:47to another row when it runs out of space1:50the width of each card is a fixed 2801:52pixels so if I give them a bit more1:54space as soon as another card is able to1:57fit it will and naturally when there's2:00less space the last item that doesn't2:02fit has to wrap to the next row but in2:05between we've got some wasted space like2:08I said these cards are a fixed width of2:10280 pixels which means anywhere between2:13an extra one and an extra 279 pixels2:17still can't fit the next card such as2:20the nature of fixed sizes not so2:22flexible so what if we take all of these2:25cards and set their with to fill instead2:29well that ain't great there's nothing2:31stopping these cards from getting as2:32narrow as they need to be to fit on a2:34single row this is where Min width comes2:37in since we don't want these cards to2:39ever get less than the 280 pixels wide2:42they were before we can add a Min width2:46and set that to 280 pixels now since2:49they can't get more narrow than 2802:51pixels they'll wrap very similarly to2:54the way they did originally except now2:56fill sizing is able to expand to occupy2:59that available space so now we get the3:01best of both worlds flexibility with3:04constraints there's still one other3:06issue and this is an extremely common3:08one as this breakpoint gets wider and3:11wider which will happen on large 4K or3:145K desktop displays things can get3:16impractically wide this block of text is3:19becoming one super long line there are3:22too many cards to a row and a card that3:24gets its own row is absolutely massive3:27if we set the section to a fixed width3:29will lose all that great flexibility you3:32might be thinking I get it just add a3:34Max width to the section but sometimes3:36the section will have a background color3:38or an image or even a video that we want3:41to fill the entire width of the browser3:43even though we want the content to stop3:45growing so a better practice would be to3:48wrap this content in a container of its3:50own to do that I'll select the children3:52of the section rightclick and choose add3:56stack this wraps a new frame around our3:59selection adds a stack layout sets the4:01width to fill and the height to fit all4:04in one step I'll just fix this Gap real4:07quick and now we can add a Max width to4:10this container if I want the max width4:12of this Frame to be the width I'm4:14currently seeing on the canvas I can4:16cheat a little bit and switch the size4:17to fixed to see how wide it actually is4:20at the moment I'll take a mental note4:22that this is 880 hit undo then type 8804:26pixels for my Max width now when this4:29breakpoint gets smaller we have all the4:31benefits of the fluid layout that we had4:33before but when things get wider the4:35content frame stops growing when it hits4:38880 pixels so things never get out of4:40control an alternative approach to this4:43that allows for some additional freedom4:44on the canvas would be to use a fixed4:46width which we can now freely and4:49Visually size the way we like it then to4:51constrain it we can switch our maxwidth4:54to relative and set it to4:57100% now I can continue to play with the4:59w of this on the canvas and it can't get5:01any wider than its parent frame and when5:04I preview we have our Fram starting off5:06at exactly the size we want and then we5:09still have that responsive behavior of5:11it flexing to get no wider than 100% of5:14its parent frame now let's look at some5:17examples of Min and Max height here we5:21have a hero section with a viewport5:22height of 100 VH which means it'll fill5:25the height of the browser's viewport no5:27matter how tall it gets but fortunately5:30also how short it5:32gets in the preview window I can squash5:35the height of the viewport down until I5:37reach a point where things at the top5:38get clipped because this content is5:40vertically centered in the stack the5:43stuff below is fine because we can5:45scroll down but scrolling up never5:47reaches the top of the Overflow at the5:50top of the preview window we can5:51actually see that here around 520 pixels5:55is about as low as we can go before5:57things get bad so mental note6:00520 back on the canvas I can select the6:02hero section frame that's set to fill6:04100% of the viewport and click here to6:06add a Min height I'll set it to 520 so6:10it can't get less tall than what we saw6:12looked okay in preview mode and when we6:15preview again there we have it the6:17height essentially goes from filling the6:19viewport to becoming fixed at 520 pixels6:23preventing the frame from clipping its6:25content now let's look at a case where6:27we have a text box with a excerpt and a6:30read more button the text box fills the6:33width of its parent and fits the height6:35of its content the text itself if the6:38text box gets more narrow the text just6:40keeps getting taller and taller and6:42taller until eventually it's6:44impractically tall and might mess with6:46the rest of my layout but what if I6:48don't want it to get longer than four6:50lines of text for example no matter how6:52much text we start with and no matter6:54how narrow its container gets that's a6:56job for Max height I'll select the text6:59box itself add a Max height set it to7:03fixed and set a value of 96 pixels why7:0796 here's a little math trick to work7:09out the max height to fit a specific7:11number of lines of text just multiply7:15the number of lines of text by the text7:17size and then again by the line height7:20so four lines of text time 16 * 1.47:25equal 96 done deal now since this text7:28is being cut off off in an arbitrary7:30place I'm going to make it fade out at7:32the bottom to make it more clear that7:34it's just a partial excerpt of text I'll7:37click the plus icon next to Styles7:39choose mask then just rotate it around7:42the other way and make it a little less7:45tall there we go now we've got a text7:48box that still fits the height of the7:50text but only until it reaches that Max7:53height of 96 pixels which perfectly fits7:56four lines of text now you've got an7:58idea of we can use Min and Max for8:01height and width to allow us to combine8:03fixed and fluid behaviors which gives us8:06the flexibility to maintain control of8:07our layouts no matter how parent frames8:10and viewports flex that's it for this8:12one I'll see you in the next one

Watch on YouTube ↗

More in this topic

8 Framer shortcuts you're probably sleeping on4:19
8 Framer shortcuts you're probably sleeping on
Layout & Design3K views · 2 months ago
Framer Update: Stack Sorting and Bento Grids2:16
Framer Update: Stack Sorting and Bento Grids
Framer Update7K views · 2 months ago
Sharing Vector Sets Across Projects (Vectors Lesson 7)3:41
Sharing Vector Sets Across Projects (Vectors Lesson 7)
Layout & Design1K views · 3 months ago
Connecting Vector Sets to the Framer CMS (Vectors Lesson 6)3:38
Connecting Vector Sets to the Framer CMS (Vectors Lesson 6)
Layout & Design2K views · 3 months ago
Animating Vectors in Framer (Vectors Lesson 5)4:25
Animating Vectors in Framer (Vectors Lesson 5)
Layout & Design4K views · 3 months ago
Customizing Vectors with Variables in Framer (Vectors Lesson 4)4:59
Customizing Vectors with Variables in Framer (Vectors Lesson 4)
Layout & Design3K views · 3 months ago
Replace component instances site-wide in Framer1:39
Replace component instances site-wide in Framer
Layout & Design4K views · 4 months ago
Creating and Organizing Vector Sets in Framer (Vectors Lesson 3)6:58
Creating and Organizing Vector Sets in Framer (Vectors Lesson 3)
Layout & Design3K views · 4 months ago

Create a free website with Framer, the website builder loved by startups, designers and agencies.