Skip to content

Types

Everything below is exported from react-native-reanimated-modal as a type. The type declarations in your node_modules document the version you installed: lib/typescript/src/types.d.ts.

type ModalAnimation = 'fade' | 'slide' | 'scale' | 'custom';
type SwipeDirection = 'up' | 'down' | 'left' | 'right';
type ModalAnimationState = 'opening' | 'sliding' | 'bouncing' | 'closing';
ModalAnimationState When
'opening' The opening animation: progress 0 → 1
'closing' The closing animation (progress 1 → 0), or the content leaving after a swipe
'sliding' The user is dragging the content
'bouncing' The content springs back after a swipe too short to close
// shared by every preset (not exported itself)
interface BaseAnimationConfig {
duration?: number; // ms, default 300
contentAnimatedStyle?: ModalAnimatedStyleFunction;
backdropAnimatedStyle?: ModalAnimatedStyleFunction;
}
interface FadeAnimationConfig extends BaseAnimationConfig {
type: 'fade';
}
interface SlideAnimationConfig extends BaseAnimationConfig {
type: 'slide';
direction?: // default 'down'
| SwipeDirection
| { start: SwipeDirection; end: SwipeDirection | SwipeDirection[] };
}
interface ScaleAnimationConfig extends BaseAnimationConfig {
type: 'scale';
scaleFactor?: number; // 0–1, default 0.8
}
interface CustomAnimationConfig extends BaseAnimationConfig {
type: 'custom';
}
type ModalAnimationConfigUnion =
| FadeAnimationConfig
| SlideAnimationConfig
| ScaleAnimationConfig
| CustomAnimationConfig;
// the config of one preset: ModalAnimationConfig<'slide'> is SlideAnimationConfig
type ModalAnimationConfig<T extends ModalAnimation> = /* … */;

Animations

The signature of contentAnimatedStyle and backdropAnimatedStyle — a worklet:

type ModalAnimatedStyleFunction = (props: {
animationState: ModalAnimationState | null;
swipeDirection?: SwipeDirection | null; // while swiped
progress: number; // 0 closed → 1 open
offsetX: number; // px, while swiped
offsetY: number; // px, while swiped
screenWidth: number;
screenHeight: number;
}) => ViewStyle;

Custom animations

interface ModalSwipeConfig {
enabled?: boolean; // default true
directions?: SwipeDirection[]; // default ['down']
threshold?: number; // px, default 100
bounceSpringConfig?: SpringConfig; // Reanimated's, default { dampingRatio: 0.5, duration: 700 }
bounceOpacityThreshold?: number; // default 0.05
}

Swipe to dismiss

interface ModalBackdropConfig {
enabled?: boolean; // default true
color?: string; // default 'black'
opacity?: number; // 0–1, default 0.7
}

Backdrop

ModalRef is the ref’s handle, { open(): void; close(): void }; ModalProps the component’s props. Both are in the Modal reference.