$ git show page-dots

Pager dots

Intermediate/anim page-dots

Carousel indicator where the active dot stretches into a pill and follows your swipe.

Main · New Architecture only · worklets live in react-native-worklets

This snippet uses APIs that didn’t change between versions, so the same code runs on Reanimated 4 and 3.

useAnimatedScrollHandlerinterpolateuseAnimatedStyle
page-dots.tsx · reanimated 4
const scrollX = useSharedValue(0); // fractional page index
const onScroll = useAnimatedScrollHandler(e => {
  scrollX.value = e.contentOffset.x / PAGE_WIDTH;
});

function Dot({ index }: { index: number }) {
  const style = useAnimatedStyle(() => {
    // 0 when this page is centered, 1 a page or more away: follows the finger
    const d = Math.min(Math.abs(scrollX.value - index), 1);
    return {
      width: interpolate(d, [0, 1], [22, 8]),
      opacity: interpolate(d, [0, 1], [1, 0.35]),
    };
  });
  return <Animated.View style={[styles.dot, style]} />; // height 8, borderRadius 4
}

<Animated.ScrollView horizontal pagingEnabled onScroll={onScroll} scrollEventThrottle={16}>
  {pages}
</Animated.ScrollView>
<View style={styles.dots}>{pages.map((_, i) => <Dot key={i} index={i} />)}</View>