# Spacing & Layout
Tailwind CSS spacing scale for consistent layouts and visual rhythm.
## Spacing Scale
Base unit: **4px (0.25rem)**
| Class | Pixels | Class | Pixels | Class | Pixels |
| ----- | ------ | ----- | ------ | ----- | ------ |
| `0` | 0px | `8` | 32px | `24` | 96px |
| `1` | 4px | `10` | 40px | `32` | 128px |
| `2` | 8px | `12` | 48px | `40` | 160px |
| `3` | 12px | `14` | 56px | `48` | 192px |
| `4` | 16px | `16` | 64px | `64` | 256px |
| `6` | 24px | `20` | 80px | `96` | 384px |
## Padding & Margin
```tsx
// All sides
All sides (16px)
// Individual sides
Different sides
// Horizontal/Vertical
Horizontal 16px, vertical 8px
// Margin (same syntax with 'm')
All sides margin
Center horizontally
Negative margin
```
## Space Between Children
```tsx
// Vertical spacing
// Horizontal spacing
```
## Flexbox Layouts
### Basic Flex
```tsx
// Horizontal
// Vertical
// Wrap
{items}
```
### Alignment
```tsx
// Justify (horizontal)
Left and right
Center
Space around
// Align (vertical)
Vertically centered
Top aligned
Bottom aligned
// Combined
Left
Right
```
### Gap
```tsx
// Gap between flex items (preferred over margin)
{items}
// Different horizontal and vertical gaps
{items}
```
## Grid Layouts
### Basic Grid
```tsx
// Simple grid
{items}
// Responsive grid
{items}
// Game card grid (common pattern)
{games.map(game => )}
```
### Column Spanning
```tsx
Spans 2 columns
1 column
1 column
Full width
```
## Page Layout Patterns
### Standard Page
```tsx
Page Title
{/* Page sections */}
```
### Two-Column Layout
```tsx
{/* Sidebar (3 columns) */}
{/* Main (9 columns) */}
```
### Card Grid
```tsx
Browse Games
Explore the collection
{games.map((game) => (
))}
```
## Container Component
Max-width container with responsive padding:
```tsx
// Basic
Content
// Responsive padding
More padding on larger screens
```
**Max Widths:**
- Mobile: 100% (with padding)
- 2xl (1400px+): 1400px fixed width
## Responsive Spacing
```tsx
// Padding
Increases on larger screens
// Margin
Section margin
// Gap
{items}
// Space between
{items}
```
## Width & Height
### Fixed Widths
```tsx
256px
384px
// Percentages
50%
33%
67%
100%
```
### Max Widths
```tsx
448px max
512px max
672px max
// Common pattern for centered content
Centered content with readable width
```
### Min/Max Heights
```tsx
Full viewport height
100% of parent
Max height 384px
```
## Best Practices
### 1. Use Consistent Spacing Units
```tsx
// Good: Consistent scale
// Bad: Arbitrary values
Title
```
### 2. Prefer Gap Over Margins
```tsx
// Good: Using gap
{items}
// Less ideal: Using margins
```
### 3. Maintain Vertical Rhythm
```tsx
```
### 4. Responsive Spacing
```tsx
// Increase spacing on larger screens
Content
```
---
Next: [Typography](./typography.md) - Font system and text styles