.flex or .inline-flex to any container or widget in the CSS Classes field, then layer in direction, alignment, and gap utilities to compose exactly the layout you need.
.flex vs .inline-flex
Both classes activate flexbox on the element, but they differ in how the container itself behaves inside its parent’s layout flow.
| Class | CSS | Container behavior |
|---|---|---|
.flex | display: flex | Takes up the full available width (block-level) |
.inline-flex | display: inline-flex | Shrinks to fit its content (inline-level) |
.flex for rows, columns, and any container that should span the full width of its parent. Use .inline-flex when the container needs to sit alongside other inline content — such as a badge inside a sentence or a small button group within a text block.
Horizontal layout
The default flex direction is row, so adding.flex alone lines children up side by side. Combine it with a gap utility to add consistent spacing between items:
Vertical layout
Add.flex-col to stack children top to bottom. This is ideal for form fields, stacked cards, and sidebar widget lists:
Inline flex
.inline-flex keeps the container in the text flow while still giving you flex alignment controls. A common use case is a label badge that sits within a heading or paragraph:
.items-center, and both stay inline with the surrounding prose.
Responsive variants
Every flex utility accepts the--on-* responsive suffix. This lets you switch an element’s display mode at specific breakpoints — a common pattern is stacking content vertically on mobile and switching to a row on wider screens:
Responsive suffixes are mobile-first and stack:
--on-s, --on-m, --on-l, --on-xl. A class without a suffix applies at every viewport size.Best practices
Apply flex to the container
Add
.flex to the parent container, not to the children. The flex children are controlled by their parent’s direction, alignment, and gap settings.Use gap instead of margins
Prefer
gap-* utilities over adding margins to individual children. Gap lives on the container and keeps children reusable across different layouts.Combine with direction early
Decide on
.flex-row or .flex-col when you add .flex. The default is row, but being explicit makes the layout easier to read and override at breakpoints.Reserve inline-flex for inline contexts
Use
.inline-flex only when the container needs to flow with surrounding text or inline elements. For standalone layout regions, .flex is almost always the right choice.Related pages
Direction & Wrap
Control flex direction and wrapping behavior
Alignment
Justify and align items on both axes
Gap
Space flex children with uniform or axis-specific gaps