0Pricing
SwiftUI Academy · Lesson

Spacing & Alignment in Stacks

Tune spacing and alignment between stacked views.

Fine-Tuning Your Stacks

You can stack views in three directions, but real layouts need control over the gaps and edges between them. Let's tune that. 🎛️

The spacing Argument

Every stack accepts a spacing value that sets the gap between its children. A bigger number spreads views farther apart.

VStack(spacing: 20) {
    Text("Top")
    Text("Bottom")
}

All lessons in this course

  1. Stacking Views Vertically
  2. Rows with HStack
  3. Layering with ZStack
  4. Spacing & Alignment in Stacks
← Back to SwiftUI Academy