Utilities
Flex
Rows and columns of things that share space — toolbars, card headers, button rows. Start with flex, then choose the direction, wrapping and who grows.
Direction
1
2
3
<div class="flex flex-col sm:flex-row gap-2">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
A column on phones, a row from sm up. flex-row-reverse and flex-col-reverse flip the order.
Wrap
Tag 1
Tag 2
Tag 3
Tag 4
Tag 5
Tag 6
Tag 7
Tag 8
Tag 9
Tag 10
<div class="flex flex-wrap gap-2">…</div>
Grow and shrink
shrink-0
flex-1 takes the rest
auto
<div class="flex gap-2">
<div class="shrink-0">shrink-0</div>
<div class="flex-1">flex-1 takes the rest</div>
<div>auto</div>
</div>
The everyday pattern: an icon or avatar that must not shrink (shrink-0), text that takes the space (flex-1, add min-w-0 so long text can cut off).
AK
Paid
Ana Kim
Placed order #10421 for the linen tote and two mugs
<div class="flex items-center gap-3 p-3 bg-surface rounded-lg">
<span class="avatar avatar-blue shrink-0">AK</span>
<div class="flex-1 min-w-0">
<div class="text-truncate font-semibold">Ana Kim</div>
<div class="text-truncate text-muted text-sm">Placed order #10421 for the linen tote and two mugs</div>
</div>
<span class="badge badge-green badge-subtle shrink-0">Paid</span>
</div>
Order
1
order-first
3
<div class="flex gap-2">
<div>1</div>
<div class="order-first">order-first</div>
<div>3</div>
</div>
Reverse
flex-row-reverse and flex-col-reverse flip the order without touching the markup.
1
2
3
<div class="flex flex-row-reverse gap-2">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
flex-1, flex-auto, flex-initial, flex-none
flex-1
flex-1 (same share)
flex-auto
flex-auto, longer text
flex-initial
flex-none never shrinks
<div class="space-y-2">
<div class="flex gap-2">
<div class="flex-1">flex-1</div>
<div class="flex-1">flex-1 (same share)</div>
</div>
<div class="flex gap-2">
<div class="flex-auto">flex-auto</div>
<div class="flex-auto">flex-auto, longer text</div>
</div>
<div class="flex gap-2">
<div class="flex-initial">flex-initial</div>
<div class="flex-none">flex-none never shrinks</div>
</div>
</div>
Order numbers
order-3
order-1
order-2
<div class="flex gap-2">
<div class="order-3">order-3</div>
<div class="order-1">order-1</div>
<div class="order-2">order-2</div>
</div>
| Class | Does |
|---|---|
flex-row · flex-col · flex-row-reverse · flex-col-reverse | direction |
flex-wrap · flex-nowrap · flex-wrap-reverse | wrapping |
flex-1 · flex-auto · flex-initial · flex-none | grow and shrink together |
grow · grow-0 · shrink · shrink-0 | one of them |
order-first · order-last · order-none · order-1 … order-6 | visual order |
| All of them | work with breakpoints: md:flex-row |