Skip to content
Back to skills

Lynx Ui View Pager

ASecurity

Build data-driven, horizontally swipeable page navigation with stable page identity, generated native page containers, optional exposure-based lazy rendering, and imperative navigation.

  • 119 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 1, 2026
developmentreact

Security analysis

A100/100

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

Scanned October 1, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Lynx Ui View Pager?

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

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

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
---
name: view-pager
description: Build data-driven, horizontally swipeable page navigation with stable page identity, generated native page containers, optional exposure-based lazy rendering, and imperative navigation.
---

# lynx-ui-view-pager

Use `ViewPager` when a collection of data should render as horizontally swipeable pages. The component generates the required direct native `viewpager-item` children.

```tsx
import { useRef } from '@lynx-js/react'
import { ViewPager } from '@lynx-js/lynx-ui'
import type { ViewPagerRef } from '@lynx-js/lynx-ui'

const pages = [
  { id: 'first', title: 'First page' },
  { id: 'second', title: 'Second page' },
]

export function Pages() {
  const pager = useRef<ViewPagerRef>(null)
  return (
    <ViewPager
      ref={pager}
      data={pages}
      getItemKey={page => page.id}
      itemStyle={{ width: '100%', height: '100%' }}
      style={{ height: '400px' }}
    >
      {page => <text>{page.title}</text>}
    </ViewPager>
  )
}
```

`getItemKey` defaults to the item index. Provide stable, unique values when pages can be inserted, removed, or reordered so page state remains attached to the correct data item. Use `itemClassName` and `itemStyle` to style every generated native item. Use `getItemProps` for per-item native class names, styles, accessibility attributes, and other native properties. Per-item styles override shared item styles; ViewPager manages item keys, refs, and children.

`initialSelectIndex` applies only at mount. Navigate later with `ref.current?.scrollToPage(index, smooth)`. `onPageChange`, `onPageWillChange`, and `onOffsetChange` receive native events; read payload fields such as the selected index from `event.detail`.

Use `main-thread:onPageChange`, `main-thread:onPageWillChange`, or `main-thread:onOffsetChange` with a `'main thread'` function when the handler must run on the main thread. These props receive the same event shapes as their regular-thread counterparts.

Pages render eagerly unless `lazyOptions.enableLazy` is true. Lazy mode renders the initial page immediately and uses Lynx exposure placeholders for the rest. Give each pager a page-unique `scene`; use `exposureLeft` and `exposureRight` to control how early neighboring pages render. Once rendered, a page stays mounted while its keyed data item remains.

The page renderer receives only `(item, index)`, not selection state. Keep selection-dependent UI outside page content or update it explicitly from `onPageChange`; native swipes do not otherwise require React to rerender the pager's page content.

Files in this skill

  • CHANGELOG.md526 B
  • LICENSE11.1 KB
  • README.md966 B
  • README_zh.md913 B
  • SKILL.md2.5 KB
  • __tests__/ViewPager.test.tsx9 KB
  • __tests__/utils.test.ts601 B
  • docs/APIReference.mdx12.8 KB
  • docs/README.mdx485 B
  • docs/README.zh.mdx467 B
  • package.json1.2 KB
  • rslib.config.ts338 B
  • src/index.tsx4.8 KB
  • src/types/index.docs.ts7.8 KB
  • src/types/index.ts225 B
  • src/utils.ts380 B
  • tsconfig.docs.json122 B
  • tsconfig.json225 B
  • vitest.config.ts520 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.