Layout & Design

Stacks and Relative Positioning in Framer (Fundamentals Lesson 6)

Stacks and Relative Positioning in Framer (Fundamentals Lesson 6)

Stacks and Relative Positioning in Framer (Fundamentals Lesson 6)

Joseph

·

8:05

·

88K views

·

About this lesson

Stacks allow us to create rows or columns of elements that automatically align, distribute, and space themselves within the available space. Which not only means less tedious scaling and repositioning for us on the canvas — but also lets us build bulletproof layouts that can flex and adapt when things change size in browser.

Stacks not only unlock relative positioning — but also new sizing options that can make elements fill their parent — or make a parent frame automatically fit its children.

In this lesson, we’re going to look at how Stacks and Relative positioned layers work, how they make our lives easier, and of course when to use them.

If you’re already familiar with auto-layout in Figma or Flexbox in CSS, you’ve got a head start — but either way, you’re in the right place because we’re going to start with the basics.

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

https://www.youtube.com/watch?v=jQoR0dQQ9XY&t=9s What stacks do and why they matter

https://www.youtube.com/watch?v=jQoR0dQQ9XY&t=20s Stacks and relative positioning

https://www.youtube.com/watch?v=jQoR0dQQ9XY&t=37s Turning frames into stacks

https://www.youtube.com/watch?v=jQoR0dQQ9XY&t=72s Relative positioning behavior in stacks

https://www.youtube.com/watch?v=jQoR0dQQ9XY&t=115s Common use cases for stacks

https://www.youtube.com/watch?v=jQoR0dQQ9XY&t=145s Fitting stacks to content

https://www.youtube.com/watch?v=jQoR0dQQ9XY&t=182s Creating stacks from scratch or wrapping layers

https://www.youtube.com/watch?v=jQoR0dQQ9XY&t=235s Default stretching behavior for new stacks

https://www.youtube.com/watch?v=jQoR0dQQ9XY&t=256s Stack properties: direction and distribution

https://www.youtube.com/watch?v=jQoR0dQQ9XY&t=326s Adjusting gaps between elements

https://www.youtube.com/watch?v=jQoR0dQQ9XY&t=355s Aligning elements on the cross axis

https://www.youtube.com/watch?v=jQoR0dQQ9XY&t=371s Using padding effectively

https://www.youtube.com/watch?v=jQoR0dQQ9XY&t=404s Wrapping elements in stacks

https://www.youtube.com/watch?v=jQoR0dQQ9XY&t=422s Applying stack layouts to breakpoint frames

https://www.youtube.com/watch?v=jQoR0dQQ9XY&t=465s 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 allow us to create rows or0:02Columns of elements that automatically0:04align distribute and spread themselves0:07out within the available space which not0:10only means less tedious scaling and0:11repositioning for us on the canvas but0:13also lets us build bulletproof layouts0:16that can flex and adapt when things in0:18the browser change size Stacks not only0:20unlock relative positioning but also new0:23sizing options that can make elements0:24fill their parent or make a parent frame0:27automatically fit its children in this0:30lesson we're going to look at how stacks0:31and relative position layers work and0:34how they make our lives easier and of0:36course when to use them if you're0:38already familiar with auto layout in0:39figma or flexbox in CSS you've got a0:42head start but either way you're in the0:44right place because we're going to start0:46with the basics let's jump0:49[Music]0:51in in the first lesson of this chapter I0:53started to get you thinking in frames0:56now I want to get you thinking in Stacks0:59first things first1:00a stack is a frame but a frame with a1:03special layout property applied you can1:06select any frame like this minimalist1:08nav bar which has some absolute position1:10text layers floating around in it and on1:13the properties panel we can click to add1:15a layout now this Frame is considered a1:19stack and automatically arranges its1:21direct child layers in either a vertical1:23column or a horizontal Row in this case1:26a horizontal row which framer guessed1:28automatically based on the arrangement1:30of layers you'll notice now when I try1:32to move one of these text boxes it1:34either snaps back into place or switches1:37places with its siblings in fact nudging1:40with the arrow keys on the keyboard1:41changes the Sorting too what you're1:44seeing here is the behavior of layers1:46set to relative positioning relative1:48layers go with the flow of the stack1:51respecting the available space and the1:53space occupied by their sibling layers1:55the stack itself is in charge of the1:57gaps padding and alignment2:00the content flows in the same order it's2:03arranged on the layers panel pretty much2:05anytime you see a set of elements evenly2:07spaced horizontally or vertically you're2:10probably looking at an opportunity to2:12use a stack the text and CTA button in a2:16hero section could be a vertical stack2:19content within a card could be a stack2:21and a row of those very cards could be2:24another stack in fact this navigation2:26bar has a stack for the logo a stack for2:29the links2:30and the whole thing itself is a stack2:33even a frame with a single child layer2:35like a button could be a stack to keep2:37the text neatly centered and padded2:39automatically even if the text changes2:42cuz Stacks have the unique ability to2:44automatically fit the content within2:46them which is great when you need the2:48size of the child layers to be in charge2:51in fact a little trick to instantly turn2:53a frame into a stack and fit to its2:55content is to rightclick and choose fit2:58content or or press shift a on the3:01keyboard the bottom line is that Stacks3:04are perfect when you want elements to3:05flow in a single Direction with3:08consistent spacing alignment and3:10distribution and they also unlock some3:12powerful sizing options for Designing3:14fluid layouts which we're going to dig3:16into in the next lesson before we dig3:19into the properties of a stack I want to3:20show you a couple other ways to create3:22them if you know you're going to need3:24one before you've even drawn a frame you3:26can draw a new frame with a vertical or3:28horizontal stack layout already applied3:31just click the layout button on the3:32toolbar choose rows or columns then drag3:36to draw your new stack on the canvas3:39it'll come with a couple of placeholder3:41layers but you can do with those what3:42you please you can also wrap a set of3:44selected layers in a stack by right-3:46clicking and choosing add stack or with3:50the shortcut option command return on a3:52Mac Control Alt Enter on a PC you'll3:56notice the new stack that gets created3:57automatically stretches to fill the3:59width its parent and fit the height of4:01its children this is actually a behavior4:03that we changed somewhat recently4:04following a bunch of requests to make4:06this method more responsive out of the4:08box you'll be glad about these defaults4:10when you spend more time designing4:11responsive layouts let's head back to4:13our Navar example and dig into the4:15properties of a stack the first and most4:18fundamental property of a stack is the4:20direction do we want things to flow4:22horizontally or vertically we consider4:25this the main axis of the stack you can4:28think of the main axis as a a stick you4:30can think of the child layers as little4:32marshmallows who doesn't love4:34marshmallows then we can decide how4:36elements are distributed across the4:37available space along the main axis are4:40the marshmallows at the start of the4:42stick the center of the stick or the end4:44of the stick you may be wondering why4:47start and end and not left and right4:50that's because the terms start and end4:52always make sense no matter which4:54direction the stat goes it's web4:56terminology the next three options give4:59us different ways to distribute across5:01all the available space space between5:04distributes the space between each5:06element with no space on the sides space5:09around puts the same amount of space5:11around each element which means the5:14space actually doubles up between5:15side-by-side elements and space evenly5:19which distributes the exact same amount5:21of space between and around each element5:25all equal gaps With Start Center and end5:27we have a property to control the gap5:30manually and we also get draggable5:32handles on the canvas to visually adjust5:34the gaps but you'll notice that every5:36element in the stack always shares the5:39same Gap if you have a scenario where5:41two or more layers need to have a5:43different Gap than the rest what do we5:45do we just wrap them in their own stack5:47easy as that back to our first example5:51we looked at how the distribute property5:52slides things along the main axis but we5:55also have a property to determine how5:57things are aligned in the other5:59direction6:00we call this perpendicular axis the6:02cross axis and we can choose Start6:05Center or end again web terminology that6:09makes sense in both directions the last6:12property is padding which is an6:13invisible cushion of space around the6:15inside of the stack you may have noticed6:18that when I set distribute to start or6:20end our layers went right up to the edge6:23this is where a little bit of padding6:24can make a big difference padding is6:26also extremely helpful when combined6:28with a height or width that's set to fit6:30contents like the button we looked at6:32earlier since the bounds of the stack6:34would otherwise clamp down too tightly6:36around the children by default padding6:39affects all sides equally but we do have6:40a toggle to show separate values for6:43each6:43side you'll also find that if you have6:46too many items to fit in the available6:48space they'll continue to run on and6:50potentially overflow for this we have6:53wrap when there's no more room in a line6:56the elements are moved to the next row6:58or column keeping elements flowing7:00without getting cut off another way to7:03use Stacks to make life easier is to7:04apply a stack layout to an entire7:06breakpoint frame similar to our layers7:09in our navigation earlier this allows us7:11to drag to rearrange entire sections of7:13our pages and means we can control7:16padding and gaps between sections we'll7:19talk about this more in the next lesson7:20but with the stack layout applied we can7:22also change the height of this brake7:23point to fit content so it'll7:26automatically grow or Shrink as we add7:28remove and resize content so you can see7:31how Stacks can be super helpful at the7:33most macro and the most micro level of7:36your layouts saving us time making our7:38layouts more consistent and keeping them7:40that way even if the size of things7:42change but this is really just the7:45beginning things get even more powerful7:47when we use the new sizing options that7:49Stacks unlock for us which is exactly7:51what we're learning in the next lesson7:53see you there

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.