<!--
{
  "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/init(id:anchor:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI14ScrollPositionV2id6anchorACx_AA9UnitPointVSgtcSHRzs8SendableRzlufc"
  },
  "title" : "init(id:anchor:)"
}
-->

# init(id:anchor:)

Creates a new scroll position to a view with a provided identity value.

```
init(id: some Hashable & Sendable, anchor: UnitPoint? = nil)
```

## Discussion

The type of the ID indicates the type of ID of views within a
scroll target layout the scroll view should look for.

---

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)