Flex

Flex utilities control direction, wrapping, alignment, and sizing of flex items. Combine with d-flex or d-inline-flex to activate flexbox layout.

Direction

Control flex direction with flex-row, flex-column, flex-row-reverse, and flex-column-reverse.

index.htmlhtml
<div class="d-flex flex-row gap-2 border rounded-sm p-2 mb-3">
  <span class="bg-surface-raised rounded-sm p-2">One</span>
  <span class="bg-surface-raised rounded-sm p-2">Two</span>
  <span class="bg-surface-raised rounded-sm p-2">Three</span>
</div>

<div class="d-flex flex-column gap-2 border rounded-sm p-2">
  <span class="bg-surface-raised rounded-sm p-2">One</span>
  <span class="bg-surface-raised rounded-sm p-2">Two</span>
  <span class="bg-surface-raised rounded-sm p-2">Three</span>
</div>
OneTwoThree
OneTwoThree

Wrap

Use flex-wrap to allow items to wrap onto new lines, flex-nowrap to keep them on one line, and flex-wrap-reverse to wrap in reverse order.

index.htmlhtml
<div class="d-flex flex-wrap gap-2 border rounded-sm p-2">
  <span class="bg-surface-raised rounded-sm p-2">One</span>
  <span class="bg-surface-raised rounded-sm p-2">Two</span>
  <span class="bg-surface-raised rounded-sm p-2">Three</span>
  <span class="bg-surface-raised rounded-sm p-2">Four</span>
  <span class="bg-surface-raised rounded-sm p-2">Five</span>
</div>
OneTwoThreeFourFive

Fill, grow, and shrink

flex-fill expands an item to fill available space. flex-grow-1 and flex-grow-0 control whether an item grows. flex-shrink-0 prevents an item from shrinking.

index.htmlhtml
<div class="d-flex gap-2 border rounded-sm p-2 mb-3">
  <span class="bg-surface-raised rounded-sm p-2">Fixed</span>
  <span class="bg-surface-raised rounded-sm p-2 flex-fill text-center">flex-fill</span>
  <span class="bg-surface-raised rounded-sm p-2">Fixed</span>
</div>

<div class="d-flex gap-2 border rounded-sm p-2 mb-3">
  <span class="bg-surface-raised rounded-sm p-2">Fixed</span>
  <span class="bg-surface-raised rounded-sm p-2 flex-grow-1 text-center">flex-grow-1</span>
  <span class="bg-surface-raised rounded-sm p-2 flex-grow-0">flex-grow-0</span>
</div>

<div class="d-flex gap-2 border rounded-sm p-2">
  <span class="bg-surface-raised rounded-sm p-2 flex-shrink-0">flex-shrink-0</span>
  <span class="bg-surface-raised rounded-sm p-2 flex-shrink-1">flex-shrink-1</span>
</div>
Fixedflex-fillFixed
Fixedflex-grow-1flex-grow-0
flex-shrink-0flex-shrink-1

Justify content

Use justify-content-* to align items along the main axis: start, center, end, between, around, evenly.

index.htmlhtml
<div class="d-flex justify-content-between border rounded-sm p-2 mb-3">
  <span class="bg-surface-raised rounded-sm p-2">Left</span>
  <span class="bg-surface-raised rounded-sm p-2">Centre</span>
  <span class="bg-surface-raised rounded-sm p-2">Right</span>
</div>

<div class="d-flex justify-content-center border rounded-sm p-2 mb-3">
  <span class="bg-surface-raised rounded-sm p-2">Centred</span>
</div>

<div class="d-flex justify-content-end border rounded-sm p-2">
  <span class="bg-surface-raised rounded-sm p-2">End</span>
</div>
LeftCentreRight
Centred
End

Align items and align self

Use align-items-* along the cross axis and align-self-* to override alignment for a single item. Values: start, center, end, baseline, stretch.

index.htmlhtml
<div class="d-flex align-items-center gap-2 border rounded-sm p-2 mb-3">
  <span class="bg-surface-raised rounded-sm p-2">Short</span>
  <span class="bg-surface-raised rounded-sm p-4">Tall item</span>
  <span class="bg-surface-raised rounded-sm p-2">Short</span>
</div>

<div class="d-flex gap-2 border rounded-sm p-2">
  <span class="bg-surface-raised rounded-sm p-2">auto</span>
  <span class="bg-surface-raised rounded-sm p-4">Tall</span>
  <span class="bg-surface-raised rounded-sm p-2 align-self-start">align-self-start</span>
  <span class="bg-surface-raised rounded-sm p-2 align-self-end">align-self-end</span>
  <span class="bg-surface-raised rounded-sm p-2 align-self-center">align-self-center</span>
</div>
ShortTall itemShort
autoTallalign-self-startalign-self-endalign-self-center

Responsive

Direction, wrap, justify-content, align-items, and align-self generate responsive variants: .flex-column@md, .justify-content-between@lg, etc.

index.htmlhtml
<div class="d-flex flex-column flex-row@md gap-3 border rounded-sm p-2">
  <span class="bg-surface-raised rounded-sm p-2">Stacked on mobile</span>
  <span class="bg-surface-raised rounded-sm p-2">Row from md up</span>
  <span class="bg-surface-raised rounded-sm p-2">Third item</span>
</div>
Stacked on mobileRow from md upThird item

Reference

ClassPropertyResponsive
.flex-rowflex-direction: rowYes
.flex-columnflex-direction: columnYes
.flex-row-reverseflex-direction: row-reverseYes
.flex-column-reverseflex-direction: column-reverseYes
.flex-wrapflex-wrap: wrapYes
.flex-nowrapflex-wrap: nowrapYes
.flex-wrap-reverseflex-wrap: wrap-reverseYes
.flex-fillflex: 1 1 autoNo
.flex-grow-0flex-grow: 0No
.flex-grow-1flex-grow: 1No
.flex-shrink-0flex-shrink: 0No
.flex-shrink-1flex-shrink: 1No
.justify-content-startjustify-content: flex-startYes
.justify-content-centerjustify-content: centerYes
.justify-content-endjustify-content: flex-endYes
.justify-content-betweenjustify-content: space-betweenYes
.justify-content-aroundjustify-content: space-aroundYes
.justify-content-evenlyjustify-content: space-evenlyYes
.align-items-startalign-items: flex-startYes
.align-items-centeralign-items: centerYes
.align-items-endalign-items: flex-endYes
.align-items-baselinealign-items: baselineYes
.align-items-stretchalign-items: stretchYes
.align-self-startalign-self: flex-startYes
.align-self-centeralign-self: centerYes
.align-self-endalign-self: flex-endYes
.align-self-baselinealign-self: baselineYes
.align-self-stretchalign-self: stretchYes
.align-self-autoalign-self: autoYes