$ git show tab-indicator

Sliding tab indicator

Advanced/anim tab-indicator

An underline moves and resizes to match the selected tab, using measured layouts.

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.

onLayoutwithSpringwidth
tab-indicator.tsx · reanimated 4
const layouts = useRef([]);
const x = useSharedValue(0), w = useSharedValue(0);
useEffect(() => {
  const l = layouts.current[active];
  if (l) { x.value = withSpring(l.x, { damping: 18 }); w.value = withSpring(l.width, { damping: 18 }); }
}, [active]);
const indicator = useAnimatedStyle(() => ({ width: w.value, transform: [{ translateX: x.value }] }));
// each tab: onLayout={e => (layouts.current[i] = e.nativeEvent.layout)}