> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# `<scroll-view>`

APISummary
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](/next/guide/ui/layout/linear-layout.md) 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>`.

**This is an example below: scroll-view**

**Entry:** `src/base`
**Bundle:** `dist/base.lynx.bundle` | Web: `dist/base.web.bundle`

```tsx {15,24}
// Copyright 2025 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { VerticalScrollItem } from "../component/scrollItem.jsx";
import { HorizontalScrollItem } from "../component/scrollItem.jsx";

export const App = () => {
  return (
    <view style={{ width: "100%", height: "100%", padding: 10, display: "linear", marginTop: 20 }}>
      <text style={{ fontSize: "20px", fontWeight: "bold", height: "40px", paddingLeft: "10px", marginTop: "10px" }}>
        Horizontal ScrollView Example
      </text>
      <scroll-view
        scroll-orientation="horizontal"
        style={{ width: "calc(100% - 10px)", height: "100px", paddingLeft: "5px", borderRadius: "10px" }}
      >
        {Array.from({ length: 20 }).map((item, index) => <HorizontalScrollItem index={index} />)}
      </scroll-view>
      <text style={{ fontSize: "20px", fontWeight: "bold", height: "40px", paddingLeft: "10px", marginTop: "10px" }}>
        Vertical ScrollView Example
      </text>
      <scroll-view
        scroll-orientation="vertical"
        style={{ width: "100%", height: "100%", paddingLeft: "5px", marginLeft: "5px" }}
      >
        {Array.from({ length: 20 }).map((item, index) => <VerticalScrollItem index={index} />)}
      </scroll-view>
    </view>
  );
};

```

v0.7.1



### Scroll Events

Use event callbacks such as [`bindscroll`](#bindscroll), [`bindscrolltoupper`](#bindscrolltoupper), and [`bindscrolltolower`](#bindscrolltolower) to monitor changes in scroll progress.

**This is an example below: scroll-view**

**Entry:** `src/event`
**Bundle:** `dist/event.lynx.bundle` | Web: `dist/event.web.bundle`

```tsx {16-24}
// Copyright 2025 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
import { root } from "@lynx-js/react";
import "./index.css";
import { VerticalScrollItem } from "../component/scrollItem.jsx";
const VerticalScrollContainer = () => {
  return (
    <view
      style={{ width: "100%", height: "100%" }}
    >
      <text className="title">ScrollView Example</text>
      <scroll-view
        scroll-orientation="vertical"
        style="width:100%; height: 100%; padding-left: 5px;margin-left:5px"
        bindscroll={(e) => {
          console.log(e.detail);
        }}
        bindscrolltoupper={(e) => {
          console.log(e.detail);
        }}
        bindscrolltolower={(e) => {
          console.log(e.detail);
        }}
      >
        {Array.from({ length: 20 }).map((item, index) => <VerticalScrollItem index={index} />)}
      </scroll-view>
    </view>
  );
};
export default VerticalScrollContainer;
root.render(<VerticalScrollContainer />);

```

v0.7.1



### 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`.

**This is an example below: scroll-view**

**Entry:** `src/sticky`
**Bundle:** `dist/sticky.lynx.bundle` | Web: `dist/sticky.web.bundle`

```tsx
// Copyright 2025 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
import { root } from "@lynx-js/react";
import { VerticalScrollItem } from "../component/scrollItem.jsx";
import { StickyItem } from "./stickyItem.jsx";

const VerticalScrollContainer = () => {
  return (
    <view style={{ width: "100%", height: "100%" }}>
      <text className="title">ScrollView Example</text>
      <scroll-view
        scroll-orientation="vertical"
        style={{ width: "100%", height: "100%", paddingLeft: "5px", marginTop: "5px", marginLeft: "5px" }}
      >
        {Array.from({ length: 20 }).map((item, index) => {
          if (index == 2) {
            return <StickyItem index={index} height={100} sticky={true} />;
          }
          return <VerticalScrollItem index={index} />;
        })}
      </scroll-view>
    </view>
  );
};
export default VerticalScrollContainer;
root.render(<VerticalScrollContainer />);

```

v0.7.1



:::tip
`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:

```tsx
<scroll-view scroll-orientation="vertical" style={{ height: '300px' }}>
  <view style={{ display: 'flex', flexDirection: 'row' }}>
    <text>First item</text>
    <text>Second item</text>
  </view>
</scroll-view>
```

:::

## Attributes

Support varies by platform and SDK version. See the [compatibility table](#compatibility) for version information. Numeric distances below use Lynx logical pixels (`px`), not physical device pixels.

### `bounces`

iOS
Desktop
Harmony
1.4

```ts
bounces?: boolean;
```

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

```ts
// Default: true
'enable-scroll'?: boolean;
```

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

```ts
// Default: 0
'initial-scroll-offset'?: number;
```

Sets the initial absolute scroll offset along the scrolling axis, in `px`. It is an initialization setting, not a controlled scroll position: use [`scrollTo`](#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

```ts
'initial-scroll-to-index'?: number;
```

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

```ts
// Default: 0
'lower-threshold'?: number;
```

Sets the distance from the ending edge, in `px`, at which [`bindscrolltolower`](#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

```ts
// Default: false
'scroll-bar-enable'?: boolean;
```

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

```ts
// Default: 'vertical'
'scroll-orientation'?: 'vertical' | 'horizontal';
```

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

```ts
// Default: 0
'upper-threshold'?: number;
```

Sets the distance from the starting edge, in `px`, at which [`bindscrolltoupper`](#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.

```ts
interface ContentSizeChangedDetail {
  scrollWidth: number;
  scrollHeight: number;
}
```

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:

```ts
interface ScrollDetail {
  scrollLeft: number;
  scrollTop: number;
  scrollWidth: number;
  scrollHeight: number;
  deltaX: number;
  deltaY: number;
}
```

`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`](#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](/next/api/lynx-api/nodes-ref/nodes-ref-invoke.md). 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.

```ts
lynx
  .createSelectorQuery()
  .select('#scroll-view')
  .invoke({
    method: 'autoScroll',
    params: {
      rate: 120,
      start: true,
    },
  })
  .exec();
```

- `rate`: numeric speed in `px` per second. Android, iOS, and HarmonyOS support positive and negative values. Clay starts automatic scrolling only for a positive rate.
- `start`: `true` starts scrolling; `false` stops 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.

```ts
interface GetScrollInfoResult {
  scrollX: number;
  scrollY: number;
  scrollRange: number;
  maxScrollOffset?: number;
}

lynx
  .createSelectorQuery()
  .select('#scroll-view')
  .invoke({
    method: 'getScrollInfo',
    success: (res: GetScrollInfoResult) => {
      console.log(res.scrollX, res.scrollY);
    },
  })
  .exec();
```

`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.

```ts
lynx
  .createSelectorQuery()
  .select('#scroll-view')
  .invoke({
    method: 'scrollBy',
    params: { offset: 100 },
    success: (res) => {
      console.log(res.consumedX, res.consumedY);
    },
  })
  .exec();
```

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.

```ts
interface ScrollToParams {
  index?: number;
  offset?: number;
  smooth?: boolean;
}

const params: ScrollToParams = { offset: 100, smooth: true };

lynx
  .createSelectorQuery()
  .select('#scroll-view')
  .invoke({
    method: 'scrollTo',
    params,
    fail: (error) => {
      console.error(error);
    },
  })
  .exec();
```

- Without `index`, `offset` is the absolute content offset in `px`, not a distance from the current position.
- With `index`, the zero-based index selects a direct child and `offset` is added to that child's position. For example, `{ index: 1, offset: 0 }` aligns the second child. On Android, use `flatten={false}` on the direct children when positioning by index.
- `offset` defaults to `0`; `smooth` defaults to `false`. Omitting `index` is not equivalent to `index: 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.

```ts
lynx
  .createSelectorQuery()
  .select('#scroll-target')
  .invoke({
    method: 'scrollIntoView',
    params: {
      scrollIntoViewOptions: {
        behavior: 'smooth',
        block: 'center',
        inline: 'start',
      },
    },
  })
  .exec();
```

`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>`](/next/api/elements/built-in/list.md). Exposure events can help defer expensive work, but do not turn `<scroll-view>` into a virtualized list or automatically remove off-screen nodes.

## Compatibility

**Compatibility Table**

**Query:** `elements.scroll-view`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/elements/scroll-view.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| scroll-view | Yes (1.5) | Yes (3.4) | Yes (1.5) | Yes (1.5) | Yes (1.5) | Yes |
| attributes | Yes (1.5) | Yes (3.4) | Yes (1.5) | Yes (1.5) | Yes (1.5) | Partial |
| attributes.bounces | No | Yes (3.4) | Yes (1.5) | Yes (3.2) | Yes (3.2) | No |
| attributes.initial-scroll-to-index | Yes (1.5) | Yes (3.4) | Yes (1.5) | Yes (4.5) | Yes (4.5) | Yes |
| attributes.scroll-orientation | Yes (1.5) | Yes (3.4) | Yes (1.5) | Yes (1.5) | Yes (1.5) | Yes |
| attributes.initial-scroll-offset | Yes (1.5) | Yes (3.4) | Yes (1.5) | Yes (3.2) | Yes (3.2) | Yes |
| attributes.enable-scroll | Yes (2.2) | Yes (3.4) | Yes (2.18) | Yes (4.0) | Yes (4.0) | Yes |
| attributes.experimental-android-enable-new-overflow | Yes (4.2) | No | No | No | No | No |
| attributes.lower-threshold | Yes (3.5) | Yes (3.5) | Yes (2.18) | Yes (4.0) | Yes (4.0) | Yes |
| attributes.scroll-bar-enable | Yes (3.5) | Yes (3.4) | Yes (2.18) | Yes (4.0) | Yes (4.0) | Yes |
| attributes.upper-threshold | Yes (3.5) | Yes (3.5) | Yes (2.18) | Yes (4.0) | Yes (4.0) | Yes |
| attributes.enable-scrollbar | No | No | No | Yes (3.0) | Yes (3.0) | Yes |
| events | Yes (1.5) | Yes (3.4) | Yes (1.5) | Yes (1.5) | Yes (1.5) | Partial |
| events.contentsizechanged | Yes (1.5) | Yes (3.4) | Yes (4.1) | Yes (2.15) | Yes (2.15) | No |
| events.bindscroll | Yes (1.5) | Yes (3.4) | Yes (2.18) | Yes (4.0) | Yes (4.0) | Yes |
| events.bindscrollend | Yes (3.5) | Yes (3.4) | Yes (3.4) | Yes (4.0) | Yes (4.0) | Yes |
| events.bindscrolltolower | Yes (1.5) | Yes (3.4) | Yes (3.4) | Yes (4.0) | Yes (4.0) | Yes |
| events.bindscrolltoupper | Yes (1.5) | Yes (3.4) | Yes (3.4) | Yes (4.0) | Yes (4.0) | Yes |
| CSS | Yes (1.5) | Yes (3.4) | Yes (1.5) | Yes (1.5) | Yes (1.5) | Yes |
| CSS.display | No | No | No | No | No | No |
| rests | Yes (1.5) | Yes (3.4) | Yes (1.5) | Yes (1.5) | Yes (1.5) | Yes |
| methods.autoScroll | Yes (2.0) | Yes (3.4) | Yes (2.18) | Yes (2.14) | Yes (2.14) | Yes |
| methods.getScrollInfo | Yes (2.13) | Yes (4.0) | Yes (2.18) | Yes (4.0) | Yes (4.0) | No |
| methods.scrollBy | Yes (1.5) | Yes (3.5) | Yes (2.18) | No | No | Yes |
| methods.scrollTo | Yes (1.5) | Yes (3.5) | Yes (2.18) | Yes (2.14) | Yes (2.14) | Yes |
| methods.takeContentScreenshot | Yes (4.0) | Yes (4.0) | Yes (4.1) | No | No | No |
| methods.boundingClientRect | Yes (1.5) | Yes (4.1) | Yes (4.1) | Yes (4.0) | Yes (4.0) | Yes |
| methods.requestAccessibilityFocus | Yes (2.8) | No | Yes (4.1) | No | No | No |
| methods.scrollIntoView | Yes (1.5) | Yes (3.5) | Yes (4.1) | Yes (4.0) | Yes (4.0) | Yes |
| methods.takeScreenshot | Yes (2.3) | Yes (4.1) | Yes (4.1) | Yes (4.0) | Yes (4.0) | No |

**`scroll-view`**

scroll-view

**`attributes`**

attributes

- **Web — Supported (version unknown):** Partial support; Web Lynx implements only part of this grouped feature.

**`attributes.bounces`**

<code>bounces</code>

**`attributes.initial-scroll-to-index`**

<code>initial-scroll-to-index</code>

**`attributes.scroll-orientation`**

<code>scroll-orientation</code>

**`attributes.initial-scroll-offset`**

<code>initial-scroll-offset</code>

**`attributes.enable-scroll`**

<code>enable-scroll</code>

**`attributes.experimental-android-enable-new-overflow`**

<code>experimental-android-enable-new-overflow</code>

**Status:** Experimental

**`attributes.lower-threshold`**

<code>lower-threshold</code>

**`attributes.scroll-bar-enable`**

<code>scroll-bar-enable</code>

**`attributes.upper-threshold`**

<code>upper-threshold</code>

**`attributes.enable-scrollbar`**

<code>enable-scrollbar</code>

**`events`**

events

- **Web — Supported (version unknown):** Partial support; Web Lynx implements only part of this grouped feature.

**`events.contentsizechanged`**

<code>contentsizechanged</code>

**`events.bindscroll`**

<code>bindscroll</code>

**`events.bindscrollend`**

<code>bindscrollend</code>

**`events.bindscrolltolower`**

<code>bindscrolltolower</code>

**`events.bindscrolltoupper`**

<code>bindscrolltoupper</code>

**`CSS`**

CSS

**`CSS.display`**

<code>display</code>

**`rests`**

All the rest

**`methods.autoScroll`**

<code>autoScroll</code>

**`methods.getScrollInfo`**

<code>getScrollInfo</code>

**`methods.scrollBy`**

<code>scrollBy</code>

**`methods.scrollTo`**

<code>scrollTo</code>

**`methods.takeContentScreenshot`**

<code>takeContentScreenshot</code>

**`methods.boundingClientRect`**

<code>boundingClientRect</code>

**`methods.requestAccessibilityFocus`**

<code>requestAccessibilityFocus</code>

**`methods.scrollIntoView`**

<code>scrollIntoView</code>

**`methods.takeScreenshot`**

<code>takeScreenshot</code>

