ScrollViewReader
The ScrollViewReader component equivalent to SwiftUI’s ScrollViewReader, allowing scripts to programmatically control scrolling position within scrollable content such as List or ScrollView.
ScrollViewProxy
ScrollViewProxy represents the programmatic interface for controlling scrolling. It is provided by ScrollViewReader during rendering.
Methods
scrollTo(id, anchor?)
Scrolls the closest scrollable container until the element with the specified key becomes visible.
Parameters
| Parameter | Type | Required | Description |
| --------- | -------------- | -------- | ----------- | -------------------------------------------------------------------------------------------------------- |
| id | string | number | Yes | The key of the target element. Must match the key assigned to a child inside the scrollable content. |
| anchor | KeywordPoint | Point | No | Controls how the target is aligned within the visible area. Optional. |
KeywordPoint
Predefined scroll alignment keywords:
'top''center''bottom'
Point
Precise alignment coordinates:
ScrollViewReader Component
Props
Behavior and Usage Notes
- ScrollViewReader must wrap a
List,ScrollView, or another scrollable container. - The
proxyis created once during rendering. UseuseRefif you need to store it. scrollToworks only with elements that have a uniquekey.- Using
withAnimationenables smooth scrolling. - The API follows React’s identity model, but scroll behavior matches SwiftUI.
Example Usage
How key Works in Scripting
Scripting does not support .id() as in SwiftUI.
Instead:
keyidentifies the element within the virtual node treescrollTo("bottom")will scroll to this elementkeymust be stable and unique, similar to React and SwiftUI’s.id()
Animation Support
Scroll operations can be wrapped in withAnimation to enable smooth transitions:
The animation behavior follows SwiftUI’s animation engine.
Important Notes
- Every scroll target must have a unique
key. scrollTowill not work without a matchingkey.- The scrollable content must be inside the same ScrollViewReader.
- The alignment anchor is optional but useful for precise positioning.
- The API mirrors SwiftUI’s ScrollViewReader logic but adopts React-style identity handling.
