0PricingLogin
SwiftUI Academy · Lesson

Adding Padding Around Views

Use padding to create breathing room.

Why Views Feel Cramped

By default a SwiftUI view sits flush against its neighbors and the screen edge. Padding is the breathing room you add so content never feels squeezed.

Meet the padding Modifier

The padding modifier adds space on the outside of a view. Attach it like any other modifier and SwiftUI grows the view's footprint to make room.

Text("Hello")
    .padding()

All lessons in this course

  1. Adding Padding Around Views
  2. Sizing Views with frame
  3. Backgrounds & Corner Radius
  4. Spacer & Layout Priority
← Back to SwiftUI Academy