Apple has always been at the forefront of user interface design, and one of their most captivating recent effects is the "liquid glass" look. This effect, characterized by its fluid, jelly-like appearance, adds a layer of depth and interactivity to UI elements. It's a subtle yet powerful way to make your applications feel more dynamic and engaging.
In this article, we'll explore how to recreate this stunning effect in your React applications using the liquid-glass-react
library.

This library provides a highly customizable and easy-to-use component that encapsulates the complexity of the effect, allowing you to add a touch of Apple's design magic to your projects with minimal effort.

Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?
Apidog delivers all your demands, and replaces Postman at a much more affordable price!
Getting Started
Before we dive into the intricacies of the liquid glass effect, let's get the liquid-glass-react
library set up in our project.
Installation
To install the library, simply run the following command in your terminal:
npm install liquid-glass-react
Or if you're using Yarn:
yarn add liquid-glass-react
Basic Usage
Once the library is installed, you can start using the LiquidGlass
component in your React application. Here's a basic example of how to use it:
import React from 'react';
import LiquidGlass from 'liquid-glass-react';
function App() {
return (
<div className="App">
<LiquidGlass>
<div style={{ padding: '20px' }}>
Hello, Liquid Glass!
</div>
</LiquidGlass>
</div>
);
}
export default App;
This will render a basic liquid glass container around the "Hello, Liquid Glass!" text. While this is a good starting point, the true power of the library lies in its extensive customization options.
Core Concepts
To fully appreciate and effectively use the liquid-glass-react
library, it's helpful to understand the core concepts that power the effect. The liquid glass effect is primarily achieved through a combination of SVG filters, displacement maps, and chromatic aberration.
SVG Filters
SVG (Scalable Vector Graphics) filters are a powerful feature of SVG that allows you to apply a wide range of effects to your graphics. In the case of the liquid glass effect, SVG filters are used to create the distortion and blur that give the component its characteristic look.
The liquid-glass-react
library uses a series of fe
(filter effect) primitives to achieve the desired effect. These include:
feGaussianBlur
: This primitive is used to create the background blur that is a key component of the glass effect.feImage
: This primitive is used to load the displacement map, which is essential for creating the distortion.feDisplacementMap
: This is the star of the show. It uses the pixel values from the displacement map to distort the source graphic.feColorMatrix
: This primitive is used to manipulate the color channels of the image, which is how the chromatic aberration effect is created.feBlend
: This primitive is used to combine the different layers of the effect, such as the red, green, and blue channels for the chromatic aberration.feComposite
: This primitive is used to combine the final effect with the original source graphic.
Displacement Maps
A displacement map is a grayscale image that is used to distort another image. The feDisplacementMap
filter uses the color values of the displacement map to shift the pixels of the source graphic. Lighter areas of the displacement map will push the pixels of the source graphic in one direction, while darker areas will push them in the opposite direction.
The liquid-glass-react
library comes with three built-in displacement maps:
standard
: A standard, smooth displacement map.polar
: A displacement map with a polar coordinate-based distortion.prominent
: A displacement map with a more pronounced, "bubbly" effect.
You can also provide your own custom displacement map, or even generate one dynamically using a shader.
Chromatic Aberration
Chromatic aberration is an optical effect that occurs when a lens fails to focus all colors to the same point. This results in a "fringing" of colors around the edges of objects. While this is generally considered an undesirable effect in photography, it can be used to create a stylish and futuristic look in digital graphics.
The liquid-glass-react
library simulates chromatic aberration by splitting the image into its red, green, and blue channels, and then displacing each channel by a slightly different amount. This creates a subtle but effective color fringing effect that adds to the overall "glassy" feel of the component.
The LiquidGlass
Component
Now that we have a basic understanding of the concepts behind the liquid glass effect, let's take a closer look at the LiquidGlass
component and its props.
The LiquidGlass
component is the main component of the library. It's a highly customizable component that allows you to control every aspect of the liquid glass effect.
Here are some of the key props that you can use to customize the component:
displacementScale
: Controls the intensity of the distortion effect. A higher value will result in a more distorted, "wobbly" look.blurAmount
: Controls the amount of blur applied to the background.saturation
: Controls the saturation of the background.aberrationIntensity
: Controls the intensity of the chromatic aberration effect.elasticity
: Controls how much the component "stretches" towards the mouse cursor. This creates a fun, interactive effect.cornerRadius
: Controls the corner radius of the component.mode
: Controls which displacement map is used. You can choose betweenstandard
,polar
,prominent
, andshader
.overLight
: A boolean that, when true, makes the glass darker for better visibility on light backgrounds.
Customization
The real fun begins when you start to play with the props of the LiquidGlass
component. By combining different props, you can create a wide range of unique and interesting effects.
Here's an example of a more customized LiquidGlass
component:
import React from 'react';
import LiquidGlass from 'liquid-glass-react';
function App() {
return (
<div className="App">
<LiquidGlass
displacementScale={100}
blurAmount={0.5}
saturation={140}
aberrationIntensity={2}
elasticity={0.35}
cornerRadius={32}
mode="polar"
overLight={false}
>
<div style={{ padding: '20px' }}>
Customized Liquid Glass
</div>
</LiquidGlass>
</div>
);
}
export default App;
In this example, we've increased the displacementScale
to create a more pronounced distortion, and we've set the mode
to polar
to use the polar displacement map. We've also added a bit of elasticity
to make the component react to the mouse cursor.

Conclusion
The liquid-glass-react
library is a powerful and easy-to-use tool for creating stunning liquid glass effects in your React applications. Whether you're a seasoned designer or a developer looking to add a bit of flair to your projects, this library has something to offer.
With its extensive customization options and advanced features, the liquid-glass-react
library is the perfect tool for creating the next generation of user interfaces. So what are you waiting for? Give it a try and see what you can create!
Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?
Apidog delivers all your demands, and replaces Postman at a much more affordable price!