<scroll-view>
Basic scrolling component supporting both horizontal and vertical scrolling. When its content area is larger than its visible area, it allows users to scroll to reveal more content.
Usage
Horizontal and Vertical Scrolling
<scroll-view> supports one scrolling axis at a time, configured by scroll-orientation (vertical by default). Give the view a bounded size along that axis so its content can exceed the visible area.
<scroll-view> uses linear layout for its direct children, with the direction determined by scroll-orientation. To use Flexbox or another layout inside the scrolling content, place the content in a child <view>.
Scroll Events
Use event callbacks such as bindscroll, bindscrolltoupper, and bindscrolltolower to monitor changes in scroll progress.
Sticky Capability
Set the sticky attribute on a direct child of <scroll-view> to keep it at the configured edge offset as the content scrolls past it. For vertical scrolling, for example, use sticky with top: 0.
sticky can only be set for direct child nodes of <scroll-view>. On Android, you need to add the flatten={false} attribute to sticky nodes.
The scroll container lays out its direct children linearly; this does not restrict the layout inside each child. A wrapper for more complex content can look like this:
Attributes
Support varies by platform and SDK version. See the compatibility table for version information. Numeric distances below use Lynx logical pixels (px), not physical device pixels.
bounces
iOS
Desktop
Harmony
1.4
Enables the bounce effect at the edges of the scrollable content. The default is true on iOS and on Clay for iOS/macOS, and false on HarmonyOS and on Clay for Windows. This attribute is not supported on Android, including Clay for Android.
enable-scroll
Android
iOS
Desktop
Harmony
1.4
Controls whether users can scroll by dragging. Setting it to false does not disable explicit positioning through scrollTo or scrollBy. On Clay, starting autoScroll also requires scrolling to be enabled.
initial-scroll-offset
Android
iOS
Desktop
Harmony
2.17
Sets the initial absolute scroll offset along the scrolling axis, in px. It is an initialization setting, not a controlled scroll position: use scrollTo for subsequent updates.
Set either initial-scroll-offset or initial-scroll-to-index, rather than relying on a cross-platform precedence rule when both are supplied.
initial-scroll-to-index
Android
iOS
Desktop
Harmony
2.17
Initially positions the content at the specified direct child. The index is zero-based. Omitting this attribute does not select a child. Like initial-scroll-offset, it is intended for initialization; use scrollTo to change the position afterward.
On Android, set flatten={false} on the direct children so their native node indices match the intended child indices. The index must refer to an existing child. Clay supports this attribute on Android, iOS, Windows, and macOS starting in version 4.5.
lower-threshold
Android
iOS
Desktop
Harmony
1.4
Sets the distance from the ending edge, in px, at which bindscrolltolower is triggered. In a vertical view this is the bottom edge; in a left-to-right horizontal view it is the right edge.
scroll-bar-enable
Android
iOS
Desktop
Harmony
1.4
Controls whether a scroll indicator is shown. Android's built-in scroll-view applies this attribute to the vertical indicator only. iOS, HarmonyOS, and Clay support indicators for both scrolling orientations.
scroll-orientation
Android
iOS
Desktop
Harmony
3.0
Sets both the scrolling axis and the linear layout direction of the direct children. Prefer this attribute to the legacy scroll-x and scroll-y attributes.
upper-threshold
Android
iOS
Desktop
Harmony
1.4
Sets the distance from the starting edge, in px, at which bindscrolltoupper is triggered. In a vertical view this is the top edge; in a left-to-right horizontal view it is the left edge.
Events
Bind event handlers on <scroll-view> and read the payload from event.detail. The event name is available as event.type, not event.detail.type.
bindcontentsizechanged
Android
iOS
Desktop
Harmony
1.6
Fires when the content size changes, not after every layout or child update.
Both dimensions describe the content, in px. This event can be used to reposition the view after its content size changes, but an update that leaves the content size unchanged does not guarantee this event.
bindscroll
Android
iOS
Desktop
Harmony
1.4
Fires as the scroll position changes. Its detail includes:
scrollLeft and scrollTop are the content offsets; scrollWidth and scrollHeight are the content dimensions. deltaX and deltaY are the change in offset reported for the event. All values use px.
bindscrollend
Android
iOS
Desktop
Harmony
1.6
Fires when scrolling ends. Its detail contains the scroll offsets and content dimensions described under bindscroll. Use the offsets to read the final position, rather than treating deltaX or deltaY as the total distance of the scroll.
bindscrolltolower
Android
iOS
Desktop
Harmony
1.4
Fires when scrolling enters the ending-edge region defined by lower-threshold: the bottom edge for vertical scrolling, or the right edge for left-to-right horizontal scrolling.
Its detail contains the same fields as bindscroll. Do not assume that deltaX and deltaY are always zero in threshold events; this differs between implementations.
bindscrolltoupper
Android
iOS
Desktop
Harmony
1.4
Fires when scrolling enters the starting-edge region defined by upper-threshold: the top edge for vertical scrolling, or the left edge for left-to-right horizontal scrolling. Its detail contains the same fields as bindscroll.
For horizontal RTL content, Android, iOS, and Clay reverse the starting and ending edges. Do not rely on identical RTL threshold behavior on HarmonyOS.
Methods
Invoke methods through SelectorQuery. The examples below assume a <scroll-view id="scroll-view"> exists and has completed layout.
autoScroll
Android
iOS
Desktop
Harmony
Starts or stops continuous scrolling along the configured axis.
rate: numeric speed inpxper second. Android, iOS, and HarmonyOS support positive and negative values. Clay starts automatic scrolling only for a positive rate.start:truestarts scrolling;falsestops it. To stop, invoke the method again with{ rate: 0, start: false }.
Use a numeric rate for portability; unit-bearing strings such as "120rpx" are not supported consistently. With the default behavior, automatic scrolling stops at the content boundary and does not restart simply because the user drags away from that boundary.
getScrollInfo
Android
iOS
Desktop
Harmony
Reads the current scroll position.
scrollX and scrollY are the content offsets in px.
The meaning of scrollRange differs by platform: Android, HarmonyOS, and Clay return the content length minus the viewport length along the scrolling axis; iOS preserves the legacy meaning of the full content length. Current iOS implementations additionally return maxScrollOffset for the maximum offset. Do not use scrollRange as a portable maximum scroll offset.
scrollBy
Android
iOS
Harmony
Moves relative to the current position along the scrolling axis. Clay does not expose this UI method.
Supply a numeric offset in px. Positive and negative values scroll in opposite directions. Unlike scrollTo, the offset is relative to the current position.
The result contains consumedX, consumedY, unconsumedX, and unconsumedY, in px. Read the pair corresponding to the scrolling axis to determine how much of the requested movement was consumed.
scrollTo
Android
iOS
Desktop
Harmony
Positions the content at an absolute offset or relative to a direct child.
- Without
index,offsetis the absolute content offset inpx, not a distance from the current position. - With
index, the zero-based index selects a direct child andoffsetis added to that child's position. For example,{ index: 1, offset: 0 }aligns the second child. On Android, useflatten={false}on the direct children when positioning by index. offsetdefaults to0;smoothdefaults tofalse. Omittingindexis not equivalent toindex: 0, for example when the first child is inset by padding or margin.
Use an existing child index and a target within the scrollable range. Out-of-range handling and callback timing differ across platforms; do not use the success callback as a cross-platform animation-completion signal. For horizontal RTL positioning by index, Android, iOS, and Clay align to the child's right edge and subtract the offset; HarmonyOS uses the child's left position plus the offset.
scrollIntoView
Android
iOS
Desktop
Harmony
Invoke this method on the target descendant, not on the scroll container, to bring the target into its ancestor scroll view. On Android, the target must have a native view; set flatten={false} when necessary.
scrollIntoViewOptions is required. Use behavior: 'smooth' for animated scrolling or 'auto' for immediate positioning. Use block for vertical alignment and inline for horizontal alignment; explicitly choose 'start', 'center', or 'end' for consistent alignment rather than relying on platform-specific defaults.
Performance Optimization Suggestions
<scroll-view> creates all supplied child nodes and does not virtualize or recycle them. Large amounts of content can increase initial rendering time and memory usage.
For long or growing collections, prefer <list>. Exposure events can help defer expensive work, but do not turn <scroll-view> into a virtualized list or automatically remove off-screen nodes.
Compatibility
LCD tables only load in the browser


