No history yet

Advanced Layouts

Stacks vs. Grids

Choosing the right layout tool is about understanding dimensionality. Think of it like organizing a room. A Stack is like a bookshelf. You can line up items horizontally or stack them vertically. It's perfect for one-dimensional arrangements: a navigation bar, a list of articles, or a user profile card. Everything follows a single, predictable line.

A Grid, on the other hand, is like a pegboard wall. You can place items anywhere in a two-dimensional space of rows and columns. This is your tool for complex, asymmetrical layouts that need to align items across both axes. Think of a photo gallery, a dashboard with various widgets, or a magazine-style page. Stacks handle one direction; Grids handle two.

A powerful approach is to use Grid for the overall layout and Flexbox for components within grid items.

In Framer, Stacks are your go-to for most component-level layouts. They are simple, fast, and predictable. Only reach for a Grid when you need to control both the horizontal and vertical position of elements in relation to each other, creating a true matrix.

Solving Sizing Puzzles

The stability of your layout depends on how you define the size of your elements. Framer gives you three primary behaviors: Fixed, , and Fill Container. Mastering them is key to avoiding broken layouts.

Sizing TypeDescriptionBest For
FixedThe element has an absolute, unchanging size (e.g., 120px width).Icons, avatars, logos, or any element that must maintain specific dimensions.
Fit ContentThe element's size is determined by the content inside it.Buttons, text boxes, tags. The container shrinks or grows to hug its contents.
Fill ContainerThe element expands to take up all available space within its parent.Main content areas, backgrounds, or elements in a stack that should share space equally.

Sizing conflicts often happen when you nest these behaviors improperly. A classic problem is placing a Fill element inside a Fit Content parent. The parent is trying to shrink to fit its children, but one of its children is trying to expand to fill the parent. This creates a circular dependency, and the layout can't be resolved.

The solution is to provide guardrails using Min and Max constraints. For instance, you can tell a Fill element inside a Fit parent to have a max-width of 100%. This breaks the conflict. The child will try to fill, but only up to the maximum boundary allowed, giving the parent a definite size to calculate.

Use min-height on text containers to prevent them from collapsing to zero when empty, and max-width on images to ensure they scale down gracefully on smaller screens without distorting the layout.

Building Bento Grids

A popular modern design pattern is the —a layout of different-sized tiles arranged in a grid, resembling a Japanese bento box. It’s a visually engaging way to present a portfolio, feature list, or dashboard.

Lesson image

Building a bento grid in Framer is a prime use case for the Grid tool. After setting up your grid with the desired number of columns and rows, you can make an element span multiple cells. You'll find options for 'Column Span' and 'Row Span' in the properties panel. By setting an item to span, say, 2 columns and 2 rows, you create a larger tile that breaks the monotony of a uniform grid.

Advanced Positioning and Nesting

Sometimes you need an element to break out of the normal layout flow. A common example is a 'New' badge on a product card or a close icon in the corner of a modal window. For this, you use absolute positioning.

The trick is to place your absolutely positioned element inside a parent container (usually a Stack or Frame) that has its position set to 'Relative'. This makes the parent the positioning context. Now, when you set the child to 'Absolute', its position (e.g., top: 8px, right: 8px) is calculated relative to the corners of its parent, not the entire page.

/* Parent Stack CSS (simplified) */
.card-stack {
  position: relative; /* Establishes positioning context */
  display: flex;
  width: 300px;
  height: 400px;
}

/* Child Element CSS */
.badge {
  position: absolute; /* Positioned relative to .card-stack */
  top: 10px;
  right: 10px;
  background-color: red;
  color: white;
  padding: 4px 8px;
}

Finally, build your layouts by nesting Stacks and Grids. Use a Grid for the main page structure—like a header, sidebar, and content area. Then, inside each of those grid cells, use Stacks to organize the content within. A sidebar might be a vertical Stack of navigation links. A content area could be a vertical Stack of article sections. This combination of tools gives you both high-level structure and fine-grained control, allowing you to build anything.

Ready to test your knowledge?

Quiz Questions 1/5

You are building a navigation bar with a logo on the left and a list of links on the right, all in a single horizontal line. Which layout tool is most appropriate for this task?

Quiz Questions 2/5

A layout is breaking because a parent container set to Fit Content contains a child element set to Fill. What is the most effective way to resolve this conflict?