$ git show accordion
Accordion
Expand and collapse content to its measured height, with a rotating chevron.
This snippet uses APIs that didn’t change between versions, so the same code runs on Reanimated 4 and 3.
const open = useSharedValue(false);
const height = useSharedValue(0);
const progress = useDerivedValue(() => withTiming(open.value ? 1 : 0));
const body = useAnimatedStyle(() => ({ height: height.value * progress.value, overflow: 'hidden' }));
const chevron = useAnimatedStyle(() => ({ transform: [{ rotate: progress.value * 180 + 'deg' }] }));
// inner content:
<View onLayout={e => (height.value = e.nativeEvent.layout.height)} style={{ position: 'absolute' }}>
{children}
</View>