Kinetik UI

Page Dots

.md

Page dots that follow the scroll: a worm that stretches to the next page, or a dot that widens into a pill.

v1.0.0Live on webreact-native-reanimatedreact-native-worklets
Component preview

Installation

Kinetik CLI
npx kinetik-ui add page-dots

The CLI copies the source and installs native dependencies with npx expo install, so versions match your Expo SDK. With shadcn: npx shadcn@latest add https://kinetik-ui.dev/r/page-dots.json

Install manually

  1. Install dependencies
    npx expo install react-native-reanimated react-native-worklets
  2. Copy the source files
    • components/kinetik/page-dots.tsx
    View source files

Usage

import Animated, { useAnimatedScrollHandler, useSharedValue } from 'react-native-reanimated';

import { PageDots } from '@/components/kinetik/page-dots';

const progress = useSharedValue(0);
const onScroll = useAnimatedScrollHandler((e) => progress.set(e.contentOffset.x / pageWidth));

<Animated.ScrollView horizontal pagingEnabled onScroll={onScroll} scrollEventThrottle={16}>
  {pages}
</Animated.ScrollView>
<PageDots count={pages.length} index={page} progress={progress} onPageChange={scrollToPage} />

Pass the scroll position as progress and the dots follow the finger on the UI thread. Without it, they spring to index.

When to use

  • Paging carousels, onboarding screens and photo viewers with up to about ten pages.
  • Showing where you are in a short, swipeable sequence.

When not to use

  • Many pages. Show "3 of 24" instead.
  • As the only way to move between pages. Keep the swipe, and add buttons where it helps.

Notes

  • worm stretches the current dot towards the next page and lets its tail catch up; expand widens the current dot and hands the width over as you swipe.
  • With onPageChange, a tap picks the nearest dot and screen reader swipes ask for the next or previous page. Scroll your pager there.
  • Keep index in step with the scroll (round the position), since screen readers and taps read it.

Props

PageDotsProps

PropTypeDefaultDescription
countrequirednumber—
indexnumber0The current page. With `progress`, still pass it: screen readers and taps read it.
progressSharedValue<number>—The scroll position in pages (1.5 is halfway from the second page to the third), e.g. from `useAnimatedScrollHandler`. The dots then follow the finger instead of jumping from page to page.
onPageChange(index: number) => void—Tapping a dot, or a screen reader swipe, asks for that page.
variant'worm' | 'expand''worm'`worm` stretches between dots; `expand` widens the current dot. Defaults to `worm`.
sizenumber8Dot diameter. Defaults to 8.
colorstring—Colour of the current page. Defaults to the theme azure.
accessibilityLabelstring'Page'Names the pager. Defaults to 'Page'.
testIDstring—
styleStyleProp<ViewStyle>—

Performance and accessibility

Performance

Budget
Reads the scroll position as a shared value on the UI thread, so it follows the finger without re-rendering. Nothing runs at rest.
Measured

Pixel 9 emulator, API 35, release build · interaction median 0.85× the system Settings app on the same emulator (indicative only) · no frames drawn at rest · 147 MB app memory

Real-device measurement pending.

Accessibility

Reduced motion
Driven by the scroll, it still follows the finger; without a scroll position it jumps between pages.
Screen readers
An adjustable value ("Page, 2 of 5") whose increment and decrement ask for the next and previous page.
Touch target
The whole row is the target, 44 pt tall; a tap picks the nearest dot.

Source files

components/kinetik/page-dots.tsx is in the Code tab of the preview above.