<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/padding(_:)-6pgqq",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE7paddingyQrAA10EdgeInsetsVF"
  },
  "title" : "padding(_:)"
}
-->

# padding(_:)

Adds a different padding amount to each edge of this view.

```
nonisolated func padding(_ insets: EdgeInsets) -> some View
```

## Parameters

`insets`

An `EdgeInsets` instance that contains
padding amounts for each edge.

## Return Value

A view that’s padded by different amounts on each edge.

## Discussion

Use this modifier to add a different amount of padding on each edge
of a view:

```
VStack {
    Text("Text padded by different amounts on each edge.")
        .padding(EdgeInsets(top: 10, leading: 20, bottom: 40, trailing: 0))
        .border(.gray)
    Text("Unpadded text for comparison.")
        .border(.yellow)
}
```

The order in which you apply modifiers matters. The example above
applies the padding before applying the border to ensure that the
border encompasses the padded region:

![A screenshot of two text strings arranged vertically, each surrounded](images/com.apple.SwiftUI/View-padding-3-iOS@2x.png)

To pad a view on specific edges with equal padding for all padded
edges, use `View/padding(_:_:)`. To pad all edges of a view
equally, use `View/padding(_:)`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)