<!--
{
  "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/offset(x:y:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE6offset1x1yQr14CoreFoundation7CGFloatV_AItF"
  },
  "title" : "offset(x:y:)"
}
-->

# offset(x:y:)

Offset this view by the specified horizontal and vertical distances.

```
nonisolated func offset(x: CGFloat = 0, y: CGFloat = 0) -> some View
```

## Parameters

`x`

The horizontal distance to offset this view.

`y`

The vertical distance to offset this view.

## Return Value

A view that offsets this view by `x` and `y`.

## Discussion

Use `offset(x:y:)` to shift the displayed contents by the amount
specified in the `x` and `y` parameters.

The original dimensions of the view aren’t changed by offsetting the
contents; in the example below the gray border drawn by this view
surrounds the original position of the text:

```
Text("Offset by passing horizontal & vertical distance")
    .border(Color.green)
    .offset(x: 20, y: 50)
    .border(Color.gray)
```

![A screenshot showing a view that offset from its original position](images/com.apple.SwiftUI/swiftui-offset-xy@2x.png)

---

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)