<!--
{
  "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(_:)-68shk",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE7paddingyQr14CoreFoundation7CGFloatVF"
  },
  "title" : "padding(_:)"
}
-->

# padding(_:)

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

```
nonisolated func padding(_ length: CGFloat) -> some View
```

## Parameters

`length`

The amount, given in points, to pad this view on all
edges.

## Return Value

A view that’s padded by the amount you specify.

## Discussion

Use this modifier to add padding all the way around a view.

```
VStack {
    Text("Text padded by 10 points on each edge.")
        .padding(10)
        .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-1-iOS@2x.png)

To independently control the amount of padding for each edge, use
`View/padding(_:)-6pgqq`. To pad a select set of edges by the
same amount, 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)