Layout & Design

Sizing to Fill and Fit Content in Framer (Fundamentals Lesson 7)

Sizing to Fill and Fit Content in Framer (Fundamentals Lesson 7)

Sizing to Fill and Fit Content in Framer (Fundamentals Lesson 7)

Joseph

·

7:37

·

65K views

·

About this lesson

Stacks not only allow us to create rows or columns of perfectly aligned and distributed elements — they also unlock two of the most powerful sizing modes in Framer… “Fill” and “Fit Content”.

Since relative positioned layers are aware of their siblings and push against one another, we can use “Fill” sizing to determine how they scale to occupy the available space — ensuring our designs are fluid and responsive across different screen sizes and devices.

On the flip side, Stacks can also be set to “Fit content” to automatically snug themselves around their child elements.

In this lesson, we’re going to dig deep into how these two sizing modes work — along with how and when to use them.

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

https://www.youtube.com/watch?v=5DYSoL26oeM&t=5s Fill and fit content sizing modes

https://www.youtube.com/watch?v=5DYSoL26oeM&t=15s How fill sizing works in stacks

https://www.youtube.com/watch?v=5DYSoL26oeM&t=22s Using fractional units (FR)

https://www.youtube.com/watch?v=5DYSoL26oeM&t=41s FR math examples

https://www.youtube.com/watch?v=5DYSoL26oeM&t=61s Mixing fill and fixed sizes

https://www.youtube.com/watch?v=5DYSoL26oeM&t=68s Benefits of fill sizing for fluid layouts

https://www.youtube.com/watch?v=5DYSoL26oeM&t=71s Introduction to fit content

https://www.youtube.com/watch?v=5DYSoL26oeM&t=86s How fit content works

https://www.youtube.com/watch?v=5DYSoL26oeM&t=112s Fit content with padding

https://www.youtube.com/watch?v=5DYSoL26oeM&t=133s Fit content shortcuts and defaults

https://www.youtube.com/watch?v=5DYSoL26oeM&t=154s Avoiding conflicts between fill and fit

https://www.youtube.com/watch?v=5DYSoL26oeM&t=175s 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:00Stacks not only allow us to create rows0:02or Columns of perfectly aligned and0:04distributed elements they also unlock0:06two of the most powerful sizing modes in0:08framer fill and fit content since0:12relative position layers are aware of0:13their siblings and push against one0:15another we can use fill sizing to0:17determine how they scale to occupy the0:19available space ensuring our designs are0:21fluid and responsive across different0:23screen sizes and devices on the flip0:26side Stacks can also be set to fit0:28content to auto automatically snug0:31themselves around their child elements0:33in this lesson we're going to dig deep0:35into how these two sizing modes work0:37along with how and when to use them0:39let's jump0:41[Music]0:42in in the previous lesson we created a0:45stack of text boxes for a minimalist0:47navbar in this case we were concerned0:49with the alignment and distribution of0:51the elements but we didn't have to worry0:53about the size because the size was0:55determined by the text itself but this0:58time let's say we're Crea a stack of1:01rectangles what size is right for each1:03one well that depends if we know we want1:07the rectangles to share the available1:08space equally with a gap between each1:10one and some padding around the sides1:13well we would have to do some math to1:15figure out the right size for each box1:18or we could have framer figure it out1:20for us this is where fill sizing comes1:23in which again is unlocked on relative1:26positioned layers within a stack or grid1:28layout when we set the the width or1:30height of a layer to fill that layer1:32takes a look at the available space1:34considering the space occupied by1:36sibling layers specifically sibling1:39layers that are also set to relative1:41positioning absolute layers don't count1:43but we'll come back to this we decide1:46how much of the available space we want1:48the layer to fill by using fractional1:50units or F fr the magic of fractional1:53units is the math they do for us when1:55multiple sibling layers are set to fill1:58all we need to do is decide what portion2:01of the available space should go to each2:03layer let's nerd out on how the math2:05works for a second let's say we have2:07three relative position siblings in a2:10horizontal stack each set to one FR2:13essentially each one of these frames is2:15requesting one portion of the space2:17please but how big is a portion well in2:20this case we have one portion plus one2:23portion plus one portion for a total of2:25three that are being requested which2:27makes each portion one out of2:30or2:311/3 sure enough each frame set to 1fr2:35gets a 1/3 share of the available space2:38so what happens if we increase a frame2:40to 2fr intuitively you may have guessed2:43that it would become twice as big as the2:45frame set to 1fr and you'd be right to2:48unpack that math a bit further there are2:50now a total of four fractional units2:52being requested 2fr plus 1R plus 1 FR or2:57four portions of available space which2:59means each of these two frames get one3:01of those two fours being set to one FR3:04and this Frame gets two fours being set3:07to two FR it's that simple just remember3:10that an FR is a fraction of the3:12available space and rather than dividing3:14by the number of layers it divides by3:16the total number of FR units of all the3:18sibling layers added up and the most3:21amazing part is that everything is3:22recalculated in real time if the amount3:25of available space changes making this3:27an incredibly powerful tool for creating3:29fluid layouts that adapt responsibly to3:31different viewport sizes another thing3:33to keep in mind is that if one of the3:35sibling layers is set to a fixed size3:38that'll eat into the available space by3:40a fixed amount if I set this third frame3:42to a fixed width there's technically now3:45less available space remaining since3:47this fixed frame ain't going to budge3:50the remaining two frames set to 1fr3:51share that remaining space equally with3:54each taking one of the total of two3:57fractional units of available space or4:001/2 so fill sizing is amazing when we4:03want child layers to expand to fill the4:05available space within their parent4:07frame now let's look at exactly the4:10opposite another superpower of stacks is4:13that they can automatically snug4:14themselves down to fit around their4:16child layers using a width or height of4:19fit content we touched on this in a4:21previous lesson a couple of times but4:24let's unpack it a bit more for those4:26situations where you want a frame to4:27wrap itself around the bounds of its4:29child layers like a card for example we4:32can choose fit content which sets the4:35value to Auto since this Dimension now4:37will set itself completely automatically4:40if the frame we're applying this to4:41doesn't have a layout applied a stack4:43layout will get applied4:45automatically why is that well it has to4:48do with what content really means when4:50we say fit content See only child layers4:53set to relative positioning are4:55considered part of the flow of content4:57and remember relative layers are4:59specific to the children of stacks and5:01grids then we can use padding to push a5:04little extra space outward from the5:06child layers and from now on it'll5:08automatically adjust when child layers5:10are added removed or change size a great5:14little trick to instantly turn a frame5:15into a stack and fit its height and5:18width to its content is to rightclick5:20and choose fit content or press shift a5:24on the keyboard and it now works on5:26component instances and text boxes too I5:29me mentioned in the previous lesson you5:30can use fit content for the height of an5:32entire breakpoint too so you never have5:34to worry about making more space or5:37getting rid of extra space manually ever5:39again it's also worth pointing out how5:41fit content works for text boxes5:43themselves too it really comes in handy5:46for example if the width of a text box5:48can Flex we usually want to allow the5:51height to adapt to the text as it5:53reflows and setting the height to fit5:55content does just that in general you5:58may often find yourself setting the6:00height of a stack to fit its content6:02since we have an unlimited amount of6:04vertical space on the web while setting6:06the width to fill in order to keep6:08things flexible for varying viewport6:11sizes in fact these settings are the6:13defaults when you use the menu item or6:15keyboard shortcut to add a stack around6:17your6:18selection while we're here I think it's6:20important to point out that I've just6:22taught you about two sizing modes that6:24can directly conflict with one another6:27if the parent is set to fit content6:29there needs to be a child layer with an6:30explicit size to support it and vice6:33versa if a child layer is going to fill6:34its parent the parent needs to have a6:36size of its own to support it someone6:39has to be in charge if you do find6:41yourself trying to do the impossible and6:43tell a child layer to fill its parent6:45while telling the parent to fit its6:47child framer tries to help by6:48automatically switching the necessary6:50layers to fix size to avoid the layout6:53collapsing in on itself you'll get a6:55little warning on the screen when this6:56happens and you can take a moment to6:58re-evaluate your decision7:00so now you know how to make the width7:02and height of elements dynamically fill7:04available space or fit the space7:07occupied by their children these are the7:09building blocks that fluid responsive7:11layouts are made of to say that7:13mastering these Concepts is key would be7:16an understatement take your time and7:18practice building some simple layouts7:20first before you go too crazy and watch7:23this video a few times if you need to7:25I'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.