Utilities
Alignment
Line things up inside flex and grid containers. justify-* works along the row, items-* across it.
Justify content
justify-start
2
3
<div class="flex justify-start gap-2">
<div>justify-start</div>
<div>2</div>
<div>3</div>
</div>
justify-center
2
3
<div class="flex justify-center gap-2">
<div>justify-center</div>
<div>2</div>
<div>3</div>
</div>
justify-end
2
3
<div class="flex justify-end gap-2">
<div>justify-end</div>
<div>2</div>
<div>3</div>
</div>
justify-between
2
3
<div class="flex justify-between gap-2">
<div>justify-between</div>
<div>2</div>
<div>3</div>
</div>
justify-around
2
3
<div class="flex justify-around gap-2">
<div>justify-around</div>
<div>2</div>
<div>3</div>
</div>
justify-evenly
2
3
<div class="flex justify-evenly gap-2">
<div>justify-evenly</div>
<div>2</div>
<div>3</div>
</div>
Align items
items-start
2
3
<div class="flex items-start gap-2">…</div>
items-center
2
3
<div class="flex items-center gap-2">…</div>
items-end
2
3
<div class="flex items-end gap-2">…</div>
items-stretch
2
3
<div class="flex items-stretch gap-2">…</div>
items-baseline
2
3
<div class="flex items-baseline gap-2">…</div>
Align self
One item lines itself up differently from the rest.
start
self-center
self-end
self-stretch
<div class="flex items-start gap-2">
<div>start</div>
<div class="self-center">self-center</div>
<div class="self-end">self-end</div>
</div>
Align content
Where wrapped rows sit when there's extra height.
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
<div class="flex flex-wrap content-between gap-2">…</div>
Justify items
In a grid: where each item sits inside its cell, across.
1
2
3
<div class="grid grid-cols-3 justify-items-center gap-2">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
Place items
Both directions at once — the quickest way to center something.
place-items-center
<div class="grid place-items-center h-36">…</div>
Justify self & place self
One grid item placed differently inside its own cell.
justify-self-start
justify-self-center
justify-self-end
<div class="grid grid-cols-3 gap-2 bg-1 rounded p-2">
<div class="justify-self-start">justify-self-start</div>
<div class="justify-self-center">justify-self-center</div>
<div class="justify-self-end">justify-self-end</div>
</div>
Place content
Where the whole grid sits when it is smaller than its box.
1
2
3
4
<style>
.two-small-cols { grid-template-columns: repeat(2, 6rem); }
</style>
<div class="grid gap-2 place-content-center bg-1 rounded h-48 two-small-cols">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
</div>
Grid flow
grid-flow-col fills columns first; grid-flow-dense fills earlier gaps with later items.
1
2
3
4
5
6
<style>
.two-rows { grid-template-rows: repeat(2, auto); }
</style>
<div class="grid grid-cols-3 grid-flow-col gap-2 two-rows">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</div>
| Class | Does |
|---|---|
justify-start · -center · -end · -between · -around · -evenly · -stretch | justify-content |
items-start · -center · -end · -stretch · -baseline | align-items |
self-auto · -start · -center · -end · -stretch · -baseline | align-self |
content-start … content-evenly · content-stretch | align-content |
justify-items-* · justify-self-* | inside grid cells, across |
place-items-* · place-content-* · place-self-* | both directions at once |
grid-flow-row · grid-flow-col · grid-flow-dense | how a grid fills in |
| All of them | work with breakpoints: md:justify-between |