Adds space around a view's content, with options for all edges, specific edges, or custom insets.
97.2% of iOS users can use this modifier
iOS 13+ required
.padding() Adds default padding to all edges
.padding(_:) Adds custom padding amount to all edges or specific edges
length: CGFloat or edges: Edge.Set.padding(_:_:) Adds custom padding to specific edges
edges: Edge.Setlength: CGFloatAdd system default padding to all edges
Text("Hello, World!")
.padding()Add 20 points of padding to all edges
Text("Hello, World!")
.padding(20)Add padding only to horizontal edges
Text("Hello, World!")
.padding(.horizontal, 30)Loading related modifiers...
The .padding() modifier requires iOS 13 or later. This means 97.2% of current iOS users can use this modifier.
Apply the .padding() modifier to any SwiftUI view. Check the code examples above for usage patterns.
Visit the official Apple documentation for detailed information.