Animate with Reanimated
Install Reanimated in your app to animate blur props such as blurAmount on the UI thread, without rendering your component again. The library itself doesn’t depend on it.
Animate the blur amount
Wrap the component with createAnimatedComponent and drive the prop with useAnimatedProps:
import Animated, {
useAnimatedProps,
useSharedValue,
withTiming,
} from 'react-native-reanimated';
import type { ReactNode } from 'react';
import { Pressable, StyleSheet } from 'react-native';
import { BlurView } from '@sbaiahmed1/react-native-blur';
const AnimatedBlurView = Animated.createAnimatedComponent(BlurView);
function Reveal({ children }: { children: ReactNode }) {
const progress = useSharedValue(0);
const blurProps = useAnimatedProps(() => ({
blurAmount: (1 - progress.get()) * 100,
}));
return (
<Pressable onPress={() => progress.set(withTiming(1, { duration: 600 }))}>
{children}
<AnimatedBlurView
blurType="regular"
animatedProps={blurProps}
pointerEvents="none"
style={StyleSheet.absoluteFill}
/>
</Pressable>
);
}
Animated styles, such as opacity or transform, apply to the whole blur view, children included.
Props that animate
These props go straight to the native view, so they animate without a render:
blurAmountonBlurView,VibrancyViewandProgressiveBlurView.startOffsetonProgressiveBlurView.glassOpacityandglassTintColoronLiquidGlassViewwhere it draws native glass. PassglassTintColorthrough theprocessColorthatreact-native-reanimatedexports, since the one fromreact-nativedoesn’t run in a worklet.
Props that don’t animate
The component works these props out in JavaScript. A change shows only after a render:
blurType. Switch it with React state.overlayColor. To animate a color over the blur, animate thebackgroundColororopacityof a childAnimated.Viewinstead.glassOpacityandglassTintColorwhereLiquidGlassViewfalls back to a blur.
Don’t animate downsampleFactor. Each new value allocates the working images of the Android 11 and earlier blur again, so set it once.
Animate a color over the blur
A child view draws above the blur. Animate its color to get the animation that overlayColor can’t give:
const tint = useAnimatedStyle(() => ({ opacity: 1 - progress.get() }));
<AnimatedBlurView animatedProps={blurProps} style={StyleSheet.absoluteFill}>
<Animated.View
style={[StyleSheet.absoluteFill, { backgroundColor: '#5E5CE633' }, tint]}
/>
</AnimatedBlurView>;
Web
On web, blur props don’t animate through Reanimated, because the blur layers are inside the view that Reanimated updates. Drive them from React state there, for example blurAmount={shown ? 0 : 100}. Animated styles on the view still work.