Skip to main content

Tailwind CSS Flexbox Cheatsheet

Complete Tailwind v4 flexbox reference with visual examples.
Click any class to copy to clipboard.

Display

ClassCSS
flexdisplay: flex;
inline-flexdisplay: inline-flex;

Flex Direction

ClassCSS
flex-rowflex-direction: row;
flex-row-reverseflex-direction: row-reverse;
flex-colflex-direction: column;
flex-col-reverseflex-direction: column-reverse;

Flex Direction - Visual Examples

flex-row

1
2
3

flex-row-reverse

1
2
3

flex-col

1
2
3

flex-col-reverse

1
2
3

Flex Wrap

ClassCSS
flex-wrapflex-wrap: wrap;
flex-wrap-reverseflex-wrap: wrap-reverse;
flex-nowrapflex-wrap: nowrap;

Flex Wrap - Visual Examples

flex-nowrap (default)

1
2
3
4
5
6

flex-wrap

1
2
3
4
5
6

flex-wrap-reverse

1
2
3
4
5
6

Justify Content

ClassCSS
justify-startjustify-content: flex-start;
justify-endjustify-content: flex-end;
justify-centerjustify-content: center;
justify-betweenjustify-content: space-between;
justify-aroundjustify-content: space-around;
justify-evenlyjustify-content: space-evenly;
justify-stretchjustify-content: stretch;

Justify Content - Visual Examples

justify-start

1
2
3

justify-center

1
2
3

justify-end

1
2
3

justify-between

1
2
3

justify-around

1
2
3

justify-evenly

1
2
3

Align Items

ClassCSS
items-startalign-items: flex-start;
items-endalign-items: flex-end;
items-centeralign-items: center;
items-baselinealign-items: baseline;
items-stretchalign-items: stretch;

Align Items - Visual Examples

items-start

A
B
C

items-center

A
B
C

items-end

A
B
C

items-baseline

A
B
C

items-stretch

A
B
C

Align Content

ClassCSS
content-startalign-content: flex-start;
content-endalign-content: flex-end;
content-centeralign-content: center;
content-betweenalign-content: space-between;
content-aroundalign-content: space-around;
content-evenlyalign-content: space-evenly;
content-stretchalign-content: stretch;

Align Self

ClassCSS
self-autoalign-self: auto;
self-startalign-self: flex-start;
self-endalign-self: flex-end;
self-centeralign-self: center;
self-stretchalign-self: stretch;
self-baselinealign-self: baseline;

Align Self - Visual Examples

The highlighted item uses align-self while container uses items-stretch

self-start

A
B
C

self-center

A
B
C

self-end

A
B
C

self-stretch

A
B
C

self-baseline

A
B
C

Flex

ClassCSS
flex-1flex: 1 1 0%;
flex-autoflex: 1 1 auto;
flex-initialflex: 0 1 auto;
flex-noneflex: none;

Flex Grow & Shrink

ClassCSS
growflex-grow: 1;
grow-0flex-grow: 0;
shrinkflex-shrink: 1;
shrink-0flex-shrink: 0;

Flex, Grow & Shrink - Visual Examples

flex-1 (all items)

flex-1
flex-1
flex-1

grow (middle item)

fixed
grow
fixed

shrink-0 (prevent shrinking)

shrink-0
This item can shrink when space is limited

flex-none vs flex-1

flex-none
flex-1
flex-1

Gap Utilities

Gap utilities use the same spacing scale as padding and margin. See the Tailwind Spacing Scale for all values.

Gap Classes

gap-*All directions
gap-x-*Horizontal gap
gap-y-*Vertical gap

Common Values

gap-28px
gap-416px
gap-624px
gap-832px

Visual Example: gap-4

1
2
3

Order

ClassCSS
order-firstorder: calc(-infinity);
order-lastorder: calc(infinity);
order-noneorder: 0;
order-1order: 1;
order-2order: 2;
order-3order: 3;
order-4order: 4;
order-5order: 5;
order-6order: 6;
order-7order: 7;
order-8order: 8;
order-9order: 9;
order-10order: 10;
order-11order: 11;
order-12order: 12;

Order - Visual Example

Items in DOM order: A, B, C - but visually reordered

A (order-3)
B (order-1)
C (order-2)
A (order-last)
B
C (order-first)

Common Patterns

Center Everything

<div class="flex items-center justify-center">
  <!-- Centered content -->
</div>

Space Between Header

<header class="flex justify-between items-center">
  <Logo />
  <Nav />
</header>

Vertical Stack

<div class="flex flex-col gap-4">
  <Card />
  <Card />
  <Card />
</div>

Responsive Row/Column

<div class="flex flex-col md:flex-row gap-4">
  <!-- Column on mobile, row on desktop -->
</div>

About Tailwind Flexbox

Tailwind's flexbox utilities map directly to CSS flexbox properties, making layouts intuitive and predictable.

Combine flex with direction, alignment, and spacing utilities to create any layout.

For responsive layouts, prefix any class with a breakpoint: md:flex-row, lg:justify-between

Flexbox Reference Pages