📱React Native Glassmorphism effect

How I created the glassmorphism effect using ChatGPT

Mikael Ainalem
5 min readJan 12, 2025
Photo by Vimal S on Unsplash

Frosted glass

Glassmorphism is a popular UI/UX design trend, known for its frosted-glass appearance created with a blend of blur, transparency, and shadows. This effect adds depth and sophistication, revealing underlying content while keeping the focus on the foreground — making it a great choice for enhancing React Native interfaces.

This article is somewhat a React Native glassmorphism tutorial and and exploration on how to use generative AI to explore visual effects. Here’s what I ended up creating, the result after a few iterations experimenting with the effect.

It all began…

The story of this article began with an itch of curiosity. After coming across a post highlighting design trends for 2025, one particular trend caught my eye — glassmorphism. Intrigued by its cool, modern aesthetic and the buzz surrounding it, I decided to dive in and experiment with the effect. My first thought? Let’s ask ChatGPT for help.

What you’re about to see is the result of multiple iterations. While ChatGPT is an incredible tool, it rarely nails a complex design concept like this one on the first try. The initial version was rough around the edges, but with some trial and error, feedback, and refining, I was able to arrive at a functional implementation of glassmorphism running in the React Native simulator. Quite quickly as well should be added. Within minutes, I had the first version up and running. It’s a testament to the iterative process of design and development, and how tools like ChatGPT can serve as a creative partner in bringing a concept to life.

The first version of the glassmorphism effect

Setting up the project

To get the app running, I started by initializing the project. Once that was done, I replaced the code in App.tsx with the version suggested by ChatGPT. This served as the foundation for implementing the glassmorphism effect.

# Initialize the project
npx @react-native-community/cli init GlassMorphismApp

# Install Cocoapods
npx pod-install

# Run the code
npx react-native run-ios

While the initial implementation wasn’t entirely what I was looking for, it was a good starting point. The result looked surprisingly decent — much like a frosted glass panel subtly overlaying an image. It captured the essence of the glassmorphism effect: a beautiful balance of blur, transparency, and style that mimicked the look of frosted glass.

This implementation of the effect builds on the @react-native-community/blur library, a library that ChatGPT suggested. To get proceed, I had to install the library and rebuild the project. Here are the necessary commands:

# Add the blur library
yarn add @react-native-community/blur

# Install the Cocoapods
npx pod-install

# Run the code again
npx react-native run-ios

Here’s the refined JSX implementation in App.tsx. At its core, the structure is simple yet effective: a BlurView component layered over an ImageBackground, with a Text component sitting on top to complete the composition.

const App: React.FC = () => {
return (
<ImageBackground
source={{
uri: 'https://images.unsplash.com/photo-1506748686214-e9df14d4d9d0?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwzNjUyOXwwfDF8c2VhcmNofDJ8fGZsb3dlcnxlbnwwfHx8fDE2ODgwMzA3NTg&ixlib=rb-4.0.3&q=80&w=1080',
}}
style={styles.background}>
<View style={styles.container}>
{/* Blurred Glass Effect */}
<BlurView
style={styles.glassEffect}
blurType="light"
blurAmount={20}
reducedTransparencyFallbackColor="white"
/>

{/* Clear Text Positioned Above the BlurView */}
<Text style={styles.text}>Glassmorphism Effect</Text>
</View>
</ImageBackground>
);
};

Making it move

But then a new idea struck me: What if the glassmorphism card could be animated? Could it move, and shift dynamically to add even more depth and interactivity? What would that look like, and how difficult would it be to achieve?

Naturally, I turned back to ChatGPT for guidance and asked the next question: “Could you animate the card?” It was time to push the boundaries of the effect and see how far it could go.

GIF animation of the glassmorphism card overlaying content

After a few more iterations, I finally managed to get the animation just right. The result is a sequence that brings the glassmorphism card to life. The animation works by resetting the initial value and then triggering a chain of animations, smoothly transitioning the card in and out of view.

const startAnimation = () => {
if (blurViewHeight > 0) {
const startValue = -(screenHeight + blurViewHeight) / 2; // Start from outside the top of the screen
const endValue = 0; // End in the middle of the screen

animatedValue.setValue(startValue); // Start animation from the calculated position

Animated.sequence([
Animated.timing(animatedValue, {
toValue: endValue, // Move to the center
duration: 4000, // Duration for the first movement
useNativeDriver: true,
}),
Animated.timing(animatedValue, {
toValue: startValue, // Move back outside the screen
duration: 4000, // Duration for the second movement
useNativeDriver: true,
}),
]).start(() => {
running.current = false; // Reset the flag
startAnimation(); // Restart the animation
});
}

A popup card

With the animation working smoothly, my next idea was to make the card dismissible, like a modal. To do so, I added a button that triggers the animation when clicked. To further enhance the visual impact, I swapped out the clean, smooth background for a more detailed and dynamic one. A busier background with higher contrast and more intricate details makes the glassmorphism effect stand out even more, highlighting its frosted-glass charm. This lead to the final result as displayed above. Here’s the code:

const App: React.FC = () => {
/* ... */

// Function to start the animation sequence
const startAnimation = /* ... */

return (
<View style={styles.container}>
{/* Background Image and Static Content */}
<View style={styles.contentContainer}>
<ImageBackground
source={{
uri: 'https://images.pexels.com/photos/905847/pexels-photo-905847.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1',
}}
style={styles.background}>
{/* Static Text */}
<View style={styles.titleContainer}>
<Text style={styles.title}>Glassmorphism Effect</Text>
</View>
</ImageBackground>
</View>

{/* Animated BlurView Container */}
<View style={styles.blurContainer}>
<Animated.View
style={[
styles.animatedBlurView,
{transform: [{translateY: animatedValue}]}, // Animate the Y position
]}>
{/* BlurView with onLayout to measure its height */}
<BlurView
style={styles.blurView}
blurType="light"
blurAmount={10}
reducedTransparencyFallbackColor="white"
onLayout={event => {
const {height} = event.nativeEvent.layout;
setBlurViewHeight(height); // Store the height dynamically
}}
/>
<Text style={styles.blurText}>Glassmorphism Effect</Text>

{/* Button to Start the Animation */}
<TouchableOpacity style={styles.button} onPress={startAnimation}>
<Text style={styles.buttonText}>Start Animation</Text>
</TouchableOpacity>
</Animated.View>
</View>
</View>
);
};

That’s a wrap, thanks for making it all the way to the end! If you enjoyed this article, don’t forget to clap, share, and follow for more content like this. Best of luck creating your own stunning glassmorphism effects!

Here’s the repo if you want to dig into the code and try out the different versions above. The code for the different versions is in the App1.tsx, App2.tsx, … files.

--

--

Mikael Ainalem
Mikael Ainalem

Written by Mikael Ainalem

Enthusiastic about software & design, father of 3, freelancer and currently CTO at Norban | twitter: https://twitter.com/mikaelainalem

No responses yet