Transition-aware components for shared elements, gesture coordination, and custom animations
Transition components are enhanced versions of React Native primitives that integrate with the screen transition system. They enable shared element animations, custom style interpolation, and gesture coordination.
import Transition from "react-native-screen-transitions";<Transition.View style={{ padding: 20 }}> <Text>This view can be animated during transitions</Text></Transition.View>
Marks this component for measurement to enable shared element transitions. Components with the same tag across different screens will animate between each other.
Connects this component to custom animated styles defined in screenStyleInterpolator. When you return custom styles from your interpolator with a matching key, those styles will be applied to this component during transitions.
Copy
// In your component:<Transition.View styleId="hero-image"> <Image source={...} /></Transition.View>// In your screenStyleInterpolator:screenStyleInterpolator: ({ progress }) => { "worklet"; return { 'hero-image': { opacity: interpolate(progress, [0, 1], [0, 1]), transform: [{ scale: interpolate(progress, [0, 1], [0.8, 1]) }] } };}
Re-measures this component when the screen regains focus and updates any matching shared-bound source link in place.Useful when layout can change while unfocused (for example, programmatic ScrollView/FlatList scrolling triggered from another screen).
Transition.View accepts all standard View props and passes them to the underlying animated component.
import Transition from "react-native-screen-transitions";<Transition.ScrollView> <Text>Scrollable content</Text> {/* More content */}</Transition.ScrollView>
Inherits all props from Transition.View plus all standard ScrollView props.
Always use Transition.ScrollView instead of React Native’s ScrollView when inside screens with gesture-enabled transitions. Regular ScrollView will not coordinate properly with dismiss gestures.
You can create your own transition-aware components using the factory function:
Copy
import Transition from "react-native-screen-transitions";import { TextInput } from "react-native";const TransitionTextInput = Transition.createTransitionAwareComponent(TextInput);// Use it like any other transition component<TransitionTextInput styleId="search-input" placeholder="Search..."/>
When animating elements between screens, always use sharedBoundTag on both source and destination. This enables accurate measurement and smooth transitions.
Use styleId for Custom Animations
For elements that need custom animations beyond the screen-level interpolator, use styleId to target specific components without affecting others.
Always Use Transition Scrollables
Replace ScrollView and FlatList with Transition.ScrollView and Transition.FlatList when inside gesture-enabled screens to ensure proper gesture coordination.
Install MaskedView for Premium Transitions
To use Instagram and Apple Music-style transitions, install @react-native-masked-view/masked-view and rebuild your app. These presets won’t work without it.