flex-flow
A shorthand that combines flex-direction and flex-wrap in one declaration.
- Initial value
row nowrap- Inherited
- No
- Animatable
- no
- Applies to
- flex containers
- JavaScript
element.style.flexFlow = "row wrap"
Example
#.gallery {
display: flex;
flex-flow: row wrap;
gap: 8px;
}<div class="gallery stage">
<div class="box" style="width: 30%">1</div><div class="box" style="width: 30%">2</div>
<div class="box" style="width: 30%">3</div><div class="box" style="width: 30%">4</div>
</div>Definition and usage
#The flex-flow property sets the main axis direction (flex-direction) and wrapping (flex-wrap) at once. You can give the values in any order, and a value you leave out falls back to its default.
flex-flow: row wrap is the most common use: items in a row that wrap onto a new line when needed. It’s shorter, but less readable for beginners, so many projects still write both properties separately.
Like any shorthand, flex-flow overwrites both of its longhand properties, including ones set earlier in other rules.
Syntax
#flex-flow: <flex-direction> || <flex-wrap>;Values
#initial
The default value: a single row with no wrapping.- A row with wrapping.
- Just a column, wrapping stays at its default.
- A reversed row with wrapping.
Values in practice
#row nowrap
.demo { flex-flow: row nowrap; }row wrap
.demo { flex-flow: row wrap; }column
.demo { flex-flow: column; }row-reverse wrap
.demo { flex-flow: row-reverse wrap; }Browser support
#Widely available
Works in all modern browsers, phones included. You can use it without worry.
- Chrome
- Edge
- Firefox
- Safari
Good practices
#- If your team doesn’t know Flexbox well, write
flex-directionandflex-wrapseparately. The code will be easier to read. - The shorthand overwrites both properties at once, so watch the order of rules in your stylesheet.
Related entries
#Spotted a mistake or missing an example? Write to us.