<!--
{
  "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/ScrollAnchorRole",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI16ScrollAnchorRoleV"
  },
  "title" : "ScrollAnchorRole"
}
-->

# ScrollAnchorRole

A type defining the role of a scroll anchor.

```
struct ScrollAnchorRole
```

## Overview

You can associate a [`UnitPoint`](/documentation/SwiftUI/UnitPoint) to a [`ScrollView`](/documentation/SwiftUI/ScrollView) using the
[`defaultScrollAnchor(_:)`](/documentation/SwiftUI/View/defaultScrollAnchor(_:)) modifier. By default, the system
uses this point for different kinds of behaviors including:

- Where the scroll view should initially be scrolled
- How the scroll view should handle content size or
  container size changes
- How the scroll view should align content smaller than
  its container size

You can further customize this behavior by assigning different unit
points for these different roles.

## Topics

### Type Properties

[`static var alignment: ScrollAnchorRole`](/documentation/SwiftUI/ScrollAnchorRole/alignment)

The role that influences how a scroll view should align
its content when the size of its content is smaller than the
container size of the scroll view.

[`static var initialOffset: ScrollAnchorRole`](/documentation/SwiftUI/ScrollAnchorRole/initialOffset)

The role that influences where a scroll view should be
initially scrolled.

[`static var sizeChanges: ScrollAnchorRole`](/documentation/SwiftUI/ScrollAnchorRole/sizeChanges)

The role that influences how a scroll view should adjust its
content offset when the scroll view’s content or container size
changes.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

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)