Shared transition props
Available from 4.8.0
Every animated component accepts two props for Shared Element Transitions. sharedTransitionTag selects the views that take part in a transition. sharedTransitionStyle selects how they move.
sharedTransitionTag
A string that pairs this view with a view on another screen. When the active SharedTransitionBoundary changes, Reanimated looks for a view with the same tag in the old boundary and in the new boundary. If it finds both, it moves the old view to the place of the new view.
Reference
import Animated from 'react-native-reanimated';
function Thumbnail({ id }) {
return (
<Animated.Image
sharedTransitionTag={`photo-${id}`}
source={{ uri: `https://picsum.photos/id/${id}/200` }}
style={{ width: 80, height: 80 }}
/>
);
}


Type definitions
interface AnimatedProps {
sharedTransitionTag?: string;
// ...
}
Remarks
- Use a tag only once on a screen. To animate more views at the same time, give each of them a different tag. For a list, build the tag from the item key, for example
`photo-${item.id}`. - Use the same native component on both screens, for example
Animated.ViewandAnimated.View, orAnimated.ImageandAnimated.Image. Do not pair anAnimated.Viewwith anAnimated.Image, or image components from two different libraries. - You can change the tag at any time. The next transition uses the new tag. To turn off the transition for a view, remove the tag or set it to an empty string.
- In a pager whose pages all have a match on the other screen, for example a details pager over a grid, give the tag only to the page that the user sees. If not, every mounted page moves to its match at the same time.
- Reanimated pairs the views when the active boundary changes. A view that mounts later, for example an image that shows after its data loads, does not move. Mount the tagged view at once with its final size, for example an
Animated.Imagewithout a source, and set the source when the data loads. See also Videos and media. - A view and its child can both have a tag. See Children with their own tag.
- The transition replaces the
enteringanimation of the target view, and the callback of that animation does not run. The view plays its entering animation only when it shows without a transition.
sharedTransitionStyle
A SharedTransition builder that sets how the view moves. Without this prop, the view uses the default transition: a 500 ms withTiming animation.
Reference
import Animated, { SharedTransition } from 'react-native-reanimated';
const transition = SharedTransition.duration(800);
function Thumbnail() {
return (
<Animated.View
sharedTransitionTag="photo"
sharedTransitionStyle={transition}
/>
);
}


Type definitions
interface AnimatedProps {
sharedTransitionStyle?: SharedTransition;
// ...
}
Example
Loading...
Remarks
- A transition uses the
sharedTransitionStyleof the view that it starts from. When you navigate forward, it uses the style of the view on the old screen. When you go back, it uses the style of the view on the screen that closes. To get the same transition in both directions, give the same builder to both views. - Create the builder once, outside of the component, or memoize it. A new builder on each render configures the transition again.
- To change how the view moves, see
SharedTransition, Children of shared views, Custom animations and Progress-based transitions.
Platform compatibility
| Android | iOS | Web |
|---|---|---|
| ✅ | ✅ | ❌ |