Stack navigator component for iOS and Android with animated transitions and gestures
—
Comprehensive collection of card transition interpolators providing platform-specific animations for screen transitions in stack navigation.
Standard iOS-style horizontal slide animation from the right edge of the screen.
/**
* Standard iOS-style slide in from the right
* @param props - Card interpolation properties
* @returns Interpolated styles for card, overlay, and shadow
*/
function forHorizontalIOS(props: StackCardInterpolationProps): StackCardInterpolatedStyle;Usage Examples:
import { CardStyleInterpolators } from '@react-navigation/stack';
// Apply to specific screen
<Stack.Screen
name="Details"
component={DetailsScreen}
options={{
cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS,
}}
/>
// Apply to all screens in navigator
<Stack.Navigator
screenOptions={{
cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS,
}}
>Standard iOS-style vertical slide animation from the bottom, typically used for modal presentations.
/**
* Standard iOS-style slide in from the bottom (used for modals)
* @param props - Card interpolation properties
* @returns Interpolated styles for card animation
*/
function forVerticalIOS(props: StackCardInterpolationProps): StackCardInterpolatedStyle;Standard iOS-style modal animation in iOS 13.
/**
* Standard iOS modal presentation style (introduced in iOS 13)
* @param props - Card interpolation properties including insets and index
* @returns Interpolated styles with scaling and dimming effects
*/
function forModalPresentationIOS(props: StackCardInterpolationProps): StackCardInterpolatedStyle;Standard Android-style fade in from the bottom for Android Oreo.
/**
* Standard Android-style fade in from the bottom for Android Oreo
* @param props - Card interpolation properties
* @returns Interpolated styles with fade and translate effects
*/
function forFadeFromBottomAndroid(props: StackCardInterpolationProps): StackCardInterpolatedStyle;Android Pie (API 28) reveal animation that slides up from the bottom with scaling.
/**
* Standard Android navigation transition for Android 9 (Pie)
* @param props - Card interpolation properties
* @returns Interpolated styles with reveal animation
*/
function forRevealFromBottomAndroid(props: StackCardInterpolationProps): StackCardInterpolatedStyle;Android 10+ scale animation that grows from the center of the screen.
/**
* Standard Android navigation transition for Android 10+ (Q)
* @param props - Card interpolation properties
* @returns Interpolated styles with center scaling animation
*/
function forScaleFromCenterAndroid(props: StackCardInterpolationProps): StackCardInterpolatedStyle;Material Design bottom sheet animation sliding up from the bottom edge.
/**
* Material Design bottom sheet animation
* @param props - Card interpolation properties
* @returns Interpolated styles for bottom sheet presentation
*/
function forBottomSheetAndroid(props: StackCardInterpolationProps): StackCardInterpolatedStyle;Simple fade animation without translation, useful for overlay-style transitions.
/**
* Simple fade animation from center without translation
* @param props - Card interpolation properties
* @returns Interpolated styles with opacity animation only
*/
function forFadeFromCenter(props: StackCardInterpolationProps): StackCardInterpolatedStyle;No animation - instant transition between screens.
/**
* No animation - instant transition
* @returns Empty style object for no animation
*/
function forNoAnimation(): StackCardInterpolatedStyle;Input properties provided to card style interpolators containing animation progress and layout information.
interface StackCardInterpolationProps {
current: {
progress: Animated.AnimatedInterpolation<number>;
};
next?: {
progress: Animated.AnimatedInterpolation<number>;
};
index: number;
closing: Animated.AnimatedInterpolation<0 | 1>;
swiping: Animated.AnimatedInterpolation<0 | 1>;
inverted: Animated.AnimatedInterpolation<-1 | 1>;
layouts: {
screen: Layout;
};
insets: {
top: number;
right: number;
bottom: number;
left: number;
};
}Output styles returned by card style interpolators for animating different parts of the card.
interface StackCardInterpolatedStyle {
containerStyle?: any;
cardStyle?: any;
overlayStyle?: any;
shadowStyle?: any;
}Usage Examples:
import { CardStyleInterpolators } from '@react-navigation/stack';
// Platform-specific animations
const platformCardStyle = Platform.select({
ios: CardStyleInterpolators.forHorizontalIOS,
android: CardStyleInterpolators.forFadeFromBottomAndroid,
});
// Modal presentations
<Stack.Screen
name="Modal"
component={ModalScreen}
options={{
presentation: 'modal',
cardStyleInterpolator: CardStyleInterpolators.forVerticalIOS,
}}
/>
// Custom animation combining interpolators
const customInterpolator = ({ current, layouts }) => {
const translateX = current.progress.interpolate({
inputRange: [0, 1],
outputRange: [layouts.screen.width, 0],
});
const opacity = current.progress.interpolate({
inputRange: [0, 0.5, 1],
outputRange: [0, 0.5, 1],
});
return {
cardStyle: {
transform: [{ translateX }],
opacity,
},
};
};
<Stack.Screen
name="Custom"
component={CustomScreen}
options={{
cardStyleInterpolator: customInterpolator,
}}
/>Card animations are coordinated with timing specifications from TransitionSpecs:
import { TransitionSpecs, CardStyleInterpolators } from '@react-navigation/stack';
// Custom transition with specific timing
<Stack.Screen
name="CustomTiming"
component={MyScreen}
options={{
cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS,
transitionSpec: {
open: TransitionSpecs.TransitionIOSSpec,
close: TransitionSpecs.TransitionIOSSpec,
},
}}
/>Install with Tessl CLI
npx tessl i tessl/npm-react-navigation--stack