Flexbox

Utilities for controlling flex container direction, wrapping, alignment, and child sizing. Use with the .flex display utility.

Class Reference

Direction

ClassProperty
.flex-rowflex-direction: row
.flex-row-reverseflex-direction: row-reverse
.flex-colflex-direction: column
.flex-col-reverseflex-direction: column-reverse

Wrap

ClassProperty
.flex-wrapflex-wrap: wrap
.flex-nowrapflex-wrap: nowrap

Align Items

ClassProperty
.items-startalign-items: flex-start
.items-endalign-items: flex-end
.items-centeralign-items: center
.items-baselinealign-items: baseline
.items-stretchalign-items: stretch

Justify Content

ClassProperty
.justify-startjustify-content: flex-start
.justify-endjustify-content: flex-end
.justify-centerjustify-content: center
.justify-betweenjustify-content: space-between

Align Self

ClassProperty
.self-startalign-self: flex-start
.self-endalign-self: flex-end
.self-centeralign-self: center
.self-stretchalign-self: stretch

Flex Shorthand

ClassProperty
.flex-1flex: 1 1 0%
.flex-autoflex: 1 1 auto
.flex-noneflex: none

Grow & Shrink

ClassProperty
.growflex-grow: 1
.grow-0flex-grow: 0
.shrinkflex-shrink: 1
.shrink-0flex-shrink: 0

Gap

ClassProperty
.gap-0gap: 0
.gap-1gap: var(--spacing-1)
.gap-2gap: var(--spacing-2)
.gap-3gap: var(--spacing-3)
.gap-4gap: var(--spacing-4)
.gap-6gap: var(--spacing-6)
.gap-8gap: var(--spacing-8)
.gap-10gap: var(--spacing-10)
.gap-12gap: var(--spacing-12)

Examples

Horizontal Navigation Bar

A common navbar pattern with logo on the left and links on the right:

Logo
HomeAboutContact
<div class="flex items-center justify-between px-4 py-3"> <span class="font-bold">Logo</span> <div class="flex items-center gap-4"> <a href="#">Home</a> <a href="#">About</a> <a href="#">Contact</a> </div> </div>

Sidebar + Content Layout

A flex layout with a fixed-width sidebar and a flexible content area:

Sidebar
Main content area grows to fill remaining space.
<div class="flex gap-4"> <aside class="shrink-0" style="width: 200px;">Sidebar</aside> <main class="flex-1">Main content</main> </div>