<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Transaction/scrollTargetAnchor",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI11TransactionV18scrollTargetAnchorAA9UnitPointVSgvp"
  },
  "title" : "scrollTargetAnchor"
}
-->

# scrollTargetAnchor

The preferred alignment of the view within a scroll view’s visible
region when scrolling to a view.

```
var scrollTargetAnchor: UnitPoint? { get set }
```

## Discussion

Use this API in conjunction with a
`ScrollViewProxy/scrollTo(_:anchor)` or when updating the binding
provided to a [`scrollPosition(id:anchor:)`](/documentation/SwiftUI/View/scrollPosition(id:anchor:)).

```
@Binding var position: Item.ID?

var body: some View {
    ScrollView {
        LazyVStack {
            ForEach(items) { item in
                ItemView(item)
            }
        }
        .scrollTargetLayout()
    }
    .scrollPosition(id: $position)
    .safeAreaInset(edge: .bottom) {
        Button("Scroll To Bottom") {
            withAnimation {
                withTransaction(\.scrollTargetAnchor, .bottom) {
                    position = items.last?.id
                }
            }
        }
    }
}
```

When used with the [`scrollPosition(id:anchor:)`](/documentation/SwiftUI/View/scrollPosition(id:anchor:)) modifier,
this value will be preferred over the anchor specified in the
modifier for the current transaction.

---

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)