---
title: "defaultScrollAnchor(_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/defaultscrollanchor(_:)"
---

# defaultScrollAnchor(_:)

Associates an anchor to control which part of the scroll view’s content should be rendered by default.

## Declaration

```swift
nonisolated func defaultScrollAnchor(_ anchor: UnitPoint?) -> some View

```

## Discussion

Discussion Use this modifier to specify an anchor to control both which part of the scroll view’s content should be visible initially and how the scroll view handles content size changes. Provide a value of center to have the scroll view start in the center of its content when a scroll view is scrollable in both axes. ScrollView([.horizontal, .vertical]) {     // initially centered content } .defaultScrollAnchor(.center) Provide a value of bottom to have the scroll view start at the bottom of its content when scrollable in the vertical axis. @Binding var items: [Item] @Binding var scrolledID: Item.ID?

ScrollView {     LazyVStack {         ForEach(items) { item in             ItemView(item)         }     } } .defaultScrollAnchor(.bottom) The user may scroll away from the initial defined scroll position. When the content size of the scroll view changes, it may consult the anchor to know how to reposition the content.

## See Also

### Managing scroll position

- [scrollPosition(_:anchor:)](swiftui/view/scrollposition(_:anchor:).md)
- [scrollPosition(id:anchor:)](swiftui/view/scrollposition(id:anchor:).md)
- [defaultScrollAnchor(_:for:)](swiftui/view/defaultscrollanchor(_:for:).md)
- [ScrollAnchorRole](swiftui/scrollanchorrole.md)
- [ScrollPosition](swiftui/scrollposition.md)
