CSS propertyFlexbox

flex-grow

Determines how eagerly an item grows to fill free space.

Initial value
0
Inherited
No
Animatable
yes, as a number
Applies to
flex items
JavaScript
element.style.flexGrow = "1"
On this page

Example

#
CSS
.search {
  display: flex;
  gap: 8px;
}

.search input {
  flex-grow: 1;
}
Preview

Definition and usage

#

The flex-grow property takes a number that says how much of the container’s free space an item gets. With the default 0, an item doesn’t grow at all.

The numbers work proportionally. If one item has flex-grow: 2 and another 1, the first one gets twice as much extra space. Note that only the free space is divided up, so items with different content don’t necessarily end up with proportional widths.

For sizes that are strictly proportional to the numbers, combine flex-grow with flex-basis: 0, most conveniently with the flex: 1 shorthand.

Syntax

#
Syntax
flex-grow: <number>;

Values

#
  • 0

    The item doesn’t grow. The free space stays empty.
  • 1

    Item 2 takes up all the free space.
  • 1, 1, 1

    Every item gets an equal share of the free space.
  • 2, 1

    Item 2 gets twice as much free space as the others.

Values in practice

#

0

The item doesn’t grow. The free space stays empty.
.target { flex-grow: 0; }

1

Item 2 takes up all the free space.
.target { flex-grow: 1; }

1, 1, 1

Every item gets an equal share of the free space.
.demo .box { flex-grow: 1; }

2, 1

Item 2 gets twice as much free space as the others.
.demo .box { flex-grow: 1; }
.target { flex-grow: 2; }

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • A search field with a button next to it is a classic case: the field gets flex-grow: 1, the button stays at its natural size.
  • For equal columns, use flex: 1 rather than flex-grow: 1 alone.

Related entries

#

Spotted a mistake or missing an example? Write to us.