Flexbox
A CSS layout mode that arranges a container's children in a row or column and distributes space between them.
In more detail
Flexbox and grid lay out direct children only, so an extra wrapper element around a child can break the layout. That is one reason the asChild pattern avoids wrappers.
Example
In the browser: Setting display: flex on a container makes its children flex items. Properties such as flex-grow, flex-shrink, flex-basis, justify-content and align-items control sizing and alignment along the main and cross axes.Related terms
- CSS Grid — A CSS layout mode that places a container's children into rows and columns.
- asChild — A prop that tells a component to render its single child element instead of its own, merging its classes, props and behaviour onto that child.
- main axis — The direction flex items are laid out in, horizontal for flex-direction: row and vertical for column.
- cross axis — The direction at right angles to a flex container's main axis, vertical for a row and horizontal for a column.
- flex-grow — The flexbox property that says how much of the leftover space an item takes, relative to the other items' grow values.
- flex-shrink — The flexbox property that says how much an item gives up when items are too big for the container, weighted by each item's base size.
- flex-basis — The flexbox property that sets an item's starting size along the main axis, before any spare space is shared out or taken away.
- CSS — The language that describes how web pages look: colours, fonts, spacing, layout and animation.
- ImageResponse — A Next.js class from next/og that turns JSX and a subset of CSS into a PNG image response.
Taught in
- Polymorphism & Slotted Composition: The asChild Pattern — Design Systems & Component Engineering
- MutationObserver: Reactive DOM Watching Without Polling — Frontend Architecture & Web Platform
- Modern Box Model, Box Sizing, Display Types And Flow Layout — Frontend Architecture & Web Platform
- Deep Flexbox: Flex Grow, Shrink, Basis And Alignment Physics — Frontend Architecture & Web Platform
- Advanced CSS Grid: Named Areas, minmax And auto-fit — Frontend Architecture & Web Platform
- CSS Subgrid: Inheriting Track Sizing Across Nested Layouts — Frontend Architecture & Web Platform
- Metadata API: Dynamic OpenGraph & Head Management — Next.js 15 & Modern App Router Architecture