<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/ScrollPosition/scrollTo(x:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI14ScrollPositionV8scrollTo1xy14CoreFoundation7CGFloatV_tF"
  },
  "title" : "scrollTo(x:)"
}
-->

# scrollTo(x:)

Scrolls the position of the scroll view to the x value you provide.

```
mutating func scrollTo(x: CGFloat)
```

## Discussion

The scroll view chooses the y value based on the content insets of
the scroll view and will clamp this value to only scroll to the
size of its actual content.

---

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)