Flexbox
CSS layout for distributing items along one axis.
See it on the 3D treeGoing deeper
A container sets a main axis, either row or column, and its children share the space along it, growing, shrinking or wrapping as allowed. Separate properties align items along the main and cross axes. When lines wrap, each is laid out independently, so columns need not line up.
Why it matters
It handles toolbars, button groups and centring cleanly, and thinking in its terms makes resizing behaviour easier to specify.
In practice
A header keeps the logo at one end and account controls at the other, with the gap absorbing changes in width.
Common mistake
Using wrapped Flexbox rows for a strict grid and then wondering why items in the last row do not line up.
Connected terms
- Auto LayoutFigma's auto layout uses similar ideas of direction, gap, growth and alignment.
- CSSFlexbox is one of CSS's layout modes.
- CSS GridBetter suited when rows and columns must align with each other.
- AlignmentIts properties control how items line up and share space.