
This is a CSS and SVG implementation of an Apple Liquid Glass-style UI with a realistic liquid distortion effect.
It recreates the look of frosted, distorted glass with specular highlights without the need for JavaScript.
Features:
- Multi-layered glass effect: Combines backdrop filters, displacement mapping, and specular highlights for realistic depth
- SVG-based distortion filters: Uses fractal noise and displacement mapping for organic glass textures
- CSS custom properties: Configurable colors, transparency levels, and highlight intensities
- Hardware-accelerated effects: Leverages GPU for smooth transitions and blur operations
See it in action:
How to use it:
1. Set up the HTML. The structure relies on a parent container with several nested children, each representing a different layer of the effect.
<div class="glass-container glass-container--rounded glass-container--large"> <div class="glass-filter"></div> <div class="glass-overlay"></div> <div class="glass-specular"></div> <div class="glass-content glass-content--inline"> ... Any content here ... </div> </div>
2. Include this SVG filter definition in your document.
<svg style="display: none">
<filter id="lg-dist" x="0%" y="0%" width="100%" height="100%">
<feTurbulence type="fractalNoise" baseFrequency="0.008 0.008" numOctaves="2" seed="92" result="noise" />
<feGaussianBlur in="noise" stdDeviation="2" result="blurred" />
<feDisplacementMap in="SourceGraphic" in2="blurred" scale="70" xChannelSelector="R" yChannelSelector="G" />
</filter>
</svg>3. Define the glass appearance and the layering logic in CSS.
:root {
--lg-bg-color: rgba(255, 255, 255, 0.25);
--lg-highlight: rgba(255, 255, 255, 0.75);
--lg-text: #ffffff;
--lg-hover-glow: rgba(255, 255, 255, 0.4);
--lg-red: #fb4268;
--lg-grey: #5b5b5b;
}
/* ========== GLASS CONTAINER ========== */
.glass-container {
position: relative;
display: flex;
font-weight: 600;
color: var(--lg-text);
cursor: pointer;
background: transparent;
border-radius: 2rem;
overflow: hidden;
box-shadow: 0 6px 6px rgba(0, 0, 0, 0.2), 0 0 20px rgba(0, 0, 0, 0.1);
transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 2.2);
}
.glass-container--rounded {
border-radius: 5rem;
margin: 0.5rem;
fill: var(--lg-grey);
}
.glass-container--small {
margin: 5rem 0 1rem;
border-radius: 5rem;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.25);
}
.glass-container--large {
min-width: 32rem;
}
.glass-container--medium {
min-width: 25rem;
}
.glass-container svg {
fill: white;
}
/* ========== GLASS ITEM ========== */
.glass-item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
border-radius: 1rem;
color: white;
transition: color 0.3s ease;
text-align: center;
}
.glass-item svg {
fill: white;
height: 50px;
margin-bottom: 0.25rem;
}
.glass-item--active {
background: rgba(0, 0, 0, 0.25);
color: black;
margin: 0 -0.5rem;
padding: 0.25rem 1.95rem;
border-radius: 5rem;
}
.glass-item--active svg {
fill: black;
}
/* ========== GLASS LAYERS ========== */
.glass-filter {
position: absolute;
inset: 0;
z-index: 0;
backdrop-filter: blur(0px);
filter: url(#lg-dist);
isolation: isolate;
}
.glass-overlay {
position: absolute;
inset: 0;
z-index: 1;
background: var(--lg-bg-color);
}
.glass-specular {
position: absolute;
inset: 0;
z-index: 2;
border-radius: inherit;
overflow: hidden;
box-shadow: inset 1px 1px 0 var(--lg-highlight),
inset 0 0 5px var(--lg-highlight);
}
.glass-content {
position: relative;
z-index: 3;
display: flex;
align-items: center;
gap: 20px;
padding: 1rem 1.5rem 0.9rem;
}
.glass-content--inline {
padding: 0.25rem 2rem 0.25rem 0.75rem;
flex: 1 1 auto;
justify-content: space-between;
}






