Skip to content
Back to skills

Lynx Ui Scroll View

ASecurity

`ScrollView` is a general-purpose scroll container used to display content that exceeds the viewport in either vertical or horizontal direction. For massive datasets, prefer `List` or `FeedList` to ensure performance.

  • 119 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added June 5, 2026
developmentapiperformance

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 20 files and shows the line behind each finding

Scanned June 5, 2026

npx -y skills add lynx-family/lynx-ui --skill lynx-ui-scroll-view --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Lynx Ui Scroll View?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Lynx Ui Scroll View
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/lynx-family-lynx-ui-scroll-view/badge)](https://www.skillsdirectory.com/skills/lynx-family-lynx-ui-scroll-view)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# lynx-ui-scroll-view SKILL

`ScrollView` is a general-purpose scroll container used to display content that exceeds the viewport in either vertical or horizontal direction. For massive datasets, prefer `List` or `FeedList` to ensure performance.

## 1. Core Capabilities

- **Vertical and Horizontal Scrolling**: Supports vertical (`scrollOrientation = 'vertical'`) and horizontal (`scrollOrientation = 'horizontal'`) scrolling.
- **BounceableOptions**: Supports edge rubber-band and bounce effects, configurable via:
  - `enableBounces`: enable/disable edge bounce
  - `singleSidedBounce`: select bounce side (`'upper' | 'lower' | 'both'`)
  - `alwaysBouncing`: allow bouncing even when content does not exceed the viewport
  - `startBounceTriggerDistance` / `endBounceTriggerDistance`: threshold distance to trigger `onScrollToBounces`
  - `onScrollToBounces(info)`: callback when reaching upper/lower edge (`info.direction` is `'upper' | 'lower'`)
  - `enableBounceEventInFling`: trigger bounce events during inertial fling
  - `validAnimationVersion`: compatibility switch to use `setTimeout` instead of `requestAnimationFrame` on lower Lynx versions

## 2. AI Coding Guide

### Minimal Usable Example

```tsx
import { ScrollView } from '@lynx-js/lynx-ui'

function BasicScrollView() {
  return (
    <ScrollView
      scrollOrientation='vertical'
      style={{ height: '300px', width: '100%' }}
    >
      <view style={{ height: '800px', background: 'lightgray' }}>
        <text>Very long content...</text>
      </view>
    </ScrollView>
  )
}
```

### Wrapper Usage (Flex Layout)

When you need `flex` layout, add a wrapper as the first child of `ScrollView`, and apply `flex` styles on that wrapper:

Also make sure the direct child of `ScrollView` is larger than the `ScrollView` viewport on the scrolling axis. Otherwise, the content does not overflow and the `ScrollView` will not scroll.

```tsx
import { ScrollView } from '@lynx-js/lynx-ui'

function FlexWrapperExample() {
  return (
    <ScrollView scrollOrientation='vertical' style={{ height: '240px' }}>
      {/* 第一层:wrapper view(设置 flex) */}
      <view style={{ display: 'flex', flexDirection: 'row', gap: '8px' }}>
        <view
          className='card'
          style={{ width: '100px', height: '100px', background: 'skyblue' }}
        />
        <view
          className='card'
          style={{ width: '100px', height: '100px', background: 'salmon' }}
        />
        <view
          className='card'
          style={{ width: '100px', height: '100px', background: 'khaki' }}
        />
      </view>
    </ScrollView>
  )
}
```

### Recommended Prompt Formula

> **Scenario Description** + **Scroll Configuration (direction, events)** + **Content and Style**

**Example Prompt:**

- "Create a vertically scrollable `ScrollView` with a height of 400px. The content within it has a total height of 1000px."
- "Implement a `ScrollView` that triggers a ‘load more’ function when scrolled to the bottom, using `onScrollToLower`."
- "Create a `ScrollView` and a ‘Back to Top’ button. When the button is clicked, smoothly scroll back to the top."

## 3. Use Cases & Best Practices

### Vertical Scrolling

```tsx
import { ScrollView } from '@lynx-js/lynx-ui'

function VerticalScrollView() {
  return (
    <ScrollView scrollY={true} style={{ height: '200px' }}>
      <view style={{ height: '500px' }}>
        {/* ... Long content ... */}
      </view>
    </ScrollView>
  )
}
```

**Example Path**: `apps/examples/src/ScrollView/Basic/index.tsx`

### Horizontal Scrolling

```tsx
import { ScrollView } from '@lynx-js/lynx-ui'

function HorizontalScrollView() {
  return (
    <ScrollView scrollOrientation='horizontal' style={{ width: '100%' }}>
      <view style={{ flexDirection: 'row' }}>
        {[...Array(10)].map((_, i) => <view key={i} className='card' />)}
      </view>
    </ScrollView>
  )
}
```

**Example Path**: `apps/examples/src/ScrollView/Basic/index.tsx`

### Listening for Scroll to Bottom (Load More)

```tsx
import { ScrollView } from '@lynx-js/lynx-ui'

function LoadMoreScrollView() {
  const loadMore = () => {
    console.log('Reached the bottom, loading more data...')
  }

  return (
    <ScrollView
      scrollY={true}
      style={{ height: '300px' }}
      onScrollToLower={loadMore}
      lower-threshold='50'
    >
      {/* ... list content ... */}
    </ScrollView>
  )
}
```

**Example Path**: `apps/examples/src/ScrollView/Event/index.tsx`

### 4. FAQ

**Q: Why can't my `ScrollView` scroll?**

A: `ScrollView` needs a determined boundary. Set a fixed size (e.g., `height: '300px'`) or place it in a flex container and use `flex: 1`. Also ensure the direct child of `ScrollView` is larger than the viewport on the scrolling axis. For example, a vertical `ScrollView` with `height: '300px'` needs a direct child taller than `300px`; otherwise it will not scroll.

**Q: `ScrollView` inside `Popup` causes drag conflicts?**

A: Pass the `main-thread:gesture` object provided by `Popup` to `ScrollView`'s `main-thread:gesture` for proper gesture arbitration.

**Q: Long lists stutter with `ScrollView` + `.map()`?**

A: Use `List` or `FeedList` for large datasets; they provide virtualization and view reuse. `ScrollView` suits limited content scenarios.

**Q: How to implement “Back to Top”?

A: Maintain a scroll position state and programmatically set `scroll-top` (or use native APIs) on interaction.

**Q: How to use flex layout inside `ScrollView`?**

A: The first-level direct child of `ScrollView` is constrained to `display: linear`. If you need `flex`, add a wrapper `view` as the first child and apply all flex-related styles to that wrapper.

## 5. Sub components

`ScrollView` is a container component. Its direct child elements are the scrollable content. There are no named child components.

Files in this skill

  • CHANGELOG.md3.1 KB
  • LICENSE11.1 KB
  • README.md1.2 KB
  • README_zh.md952 B
  • SKILL.md5.7 KB
  • docs/APIReference.mdx37.8 KB
  • docs/README.mdx984 B
  • docs/README.zh.mdx980 B
  • docs/useBounce.mdx2.9 KB
  • docs/useBounce.zh.mdx4.6 KB
  • package.json1.2 KB
  • rslib.config.ts338 B
  • src/ScrollViewBasic.tsx1.2 KB
  • src/ScrollViewWithBouncesHook.tsx5.8 KB
  • src/hooks/useBounce.tsx31 KB
  • src/index.tsx7.7 KB
  • src/types/index.docs.ts14 KB
  • src/types/index.ts225 B
  • tsconfig.docs.json122 B
  • tsconfig.json141 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.