Course contentsShow
← Web Development
Lesson 280 of 2,9825. FlexboxFree lesson

flex-grow: Distributing Extra Space

Control how flex items expand to fill available space in the container.

flex-grow: Distributing Extra Space

You'll learn how to control which flex items expand to fill leftover space in a flex container.

The Core Idea

By default, flex items only take up as much space as their content needs. But what happens when there's extra space left in the container? The flex-grow property lets you decide which items should expand to absorb that empty space—and how much of it each should take.

Think of it like a group of friends sharing leftover pizza. If everyone sets flex-grow: 0 (the default), the leftover slices just sit there. But if some people say "I'll take extra," they get to share those leftovers proportionally.

How It Works

flex-grow accepts a number (usually 0 or a positive integer):

  • flex-grow: 0 (default) — Item won't grow; keeps its base size
  • flex-grow: 1 — Item will claim its share of extra space
  • flex-grow: 2 — Item will claim twice as much extra space as items with flex-grow: 1
.container {
  display: flex;
  gap: 1rem;
}

.item-a {
  flex-grow: 0; /* Won't expand */
}

.item-b {
  flex-grow: 1; /* Gets 1 part of extra space */
}

.item-c {
  flex-grow: 2; /* Gets 2 parts of extra space */
}

If your container has 300px of extra space, item B gets 100px and item C gets 200px. Item A stays its original size.

Common Pattern

Setting flex-grow: 1 on all items makes them share extra space equally—perfect for evenly-sized navigation buttons or form inputs.

Key Takeaway: flex-grow controls whether flex items expand into available space, with higher values claiming proportionally more of the leftover room.