Appearance
flex-grow
The flex-grow component allows an item to expand and fill available space within a flexbox container. This is especially useful for creating flexible layouts where some elements need to take up remaining space.
Example
In this example, the middle element expands to fill all available space:
Multiple Growing Elements
You can apply flex-grow to multiple elements. Available space will be distributed evenly among all growing elements:
Props
| Property | Type | Default | Description |
|---|---|---|---|
| - | boolean | true | When present (or set to true), enables flex-grow |
How It Works
- The
flex-growcomponent stores the original dimension of the element - When layout is applied, it:
- Calculates remaining free space in the flexbox container
- Distributes that space among all elements with
flex-grow - Adjusts positions of elements to maintain proper spacing
Usage Tips
flex-growworks in both row and column directions- When the flexbox container changes size (e.g., due to viewport changes), growing elements automatically adjust
- You can disable growing by setting
flex-grow="false" - For predictable layouts, fix the size of non-growing elements
- Combine with
flex-colfor responsive, flexible layouts:
html
In this example, the second element takes up 9/12 of the width but can still grow to fill any additional space.
