---
name: layout-flexbox
description: Flexbox layout utilities including flex-direction, justify, items, gap, grow, shrink, and wrap
---
# Flexbox
Utilities for building flex layouts: direction, alignment, gap, and item sizing.
## Usage
### Flex direction and wrap
```html
Horizontal (default)
Reversed
Vertical
Vertical reversed
Wrap when needed
No wrap (default)
Wrap reversed
```
### Justify content
```html
Start
End
Center
Space between
Space around
Space evenly
```
### Align items
```html
Align start
Align end
Center (common)
Baseline
Stretch (default)
```
### Align self (on flex children)
```html
Auto
Start
Center
Stretch
```
### Gap
```html
gap-4 (1rem)
Different x/y gap
No gap
```
### Flex grow, shrink, basis
```html
Fixed
Grows and shrinks
Shrink only
Grow/shrink with initial size
```
- `flex-1` = `flex: 1 1 0%` - equal distribution
- `flex-initial` = `flex: 0 1 auto` - shrink, don't grow
- `flex-auto` = `flex: 1 1 auto` - grow/shrink from content size
- `flex-none` = `flex: none` - no grow or shrink
### Order
```html
```
## Key Points
- Use `flex` or `inline-flex` as container (see layout-display)
- Direction: `flex-row`, `flex-col`, `flex-row-reverse`, `flex-col-reverse`
- Justify: `justify-start`, `justify-center`, `justify-between`, `justify-evenly`
- Align: `items-center`, `items-start`, `items-stretch`
- Gap: `gap-{n}`, `gap-x-{n}`, `gap-y-{n}` (spacing scale)
- Item sizing: `flex-1`, `flex-none`, `flex-auto`, `flex-initial`
- Self alignment: `self-center`, `self-start`, etc.
- Order: `order-{n}`, `order-first`, `order-last`