1. Bending light through the glass
To make glass look real, we want to distort the background picture behind it. We use a small, hidden SVG filter to generate light ripple patterns first, smooth them out with simple blurs, and then shift the actual pixels underneath. It gives everything resting behind your container a lovely physical warping effect.
<svg style={{ display: "none" }}>
<filter id="glass-distortion" x="0%" y="0%" width="100%" height="100%">
{/* 1. Generate organic fractal noise */}
<feTurbulence
type="fractalNoise"
baseFrequency="0.001 0.005"
numOctaves="1"
seed="17"
result="turbulence"
/>
{/* 2. Adjust mapping transfer attributes */}
<feComponentTransfer in="turbulence" result="mapped">
<feFuncR type="gamma" amplitude="1" exponent="10" offset="0.5" />
<feFuncG type="gamma" amplitude="0" exponent="1" offset="0" />
<feFuncB type="gamma" amplitude="0" exponent="1" offset="0.5" />
</feComponentTransfer>
{/* 3. Smooth out high-frequency noise fields */}
<feGaussianBlur in="turbulence" stdDeviation="3" result="softMap" />
{/* 4. Warp the underlying elements based on our noise map */}
<feDisplacementMap
in="SourceGraphic"
in2="softMap"
scale="200"
xChannelSelector="R"
yChannelSelector="G"
/>
</filter>
</svg>2. Creating brilliant edge reflections
Glass has a shiny surface that catches nearby light. We can add a simple lighting filter to simulate an overhead bulb. This creates realistic, bright white highlights on the curved edges, giving your card a three-dimensional depth and premium finish without slowing down the page.
<feSpecularLighting
in="softMap"
surfaceScale="5"
specularConstant="1"
specularExponent="100"
lightingColor="white"
result="specLight"
>
<fePointLight x="-200" y="-200" z="300" />
</feSpecularLighting>
<feComposite
in="specLight"
operator="arithmetic"
k1="0" k2="1" k3="1" k4="0"
result="litImage"
/>3. Stacking layers like a real glass sandwich
Using just one transparent box looks fake and flat. Good glass is built of several overlapping layers. Our bottom layer handles the heavy distortion filter and blurring. The middle layer adds a semi-transparent white wash to catch background colors. The top border layer adds thin white highlights, and our actual text is placed completely on top so it stays crisp and perfectly easy to read.
const GlassEffect = ({ children }) => {
return (
<div className="relative overflow-hidden cursor-pointer" style={{ boxShadow: "0 6px 6px rgba(0,0,0,0.2)" }}>
{/* Layer 1: Refraction refraction and blurring */}
<div
className="absolute inset-0 z-0 overflow-hidden rounded-3xl"
style={{
backdropFilter: "blur(3px)",
filter: "url(#glass-distortion)",
isolation: "isolate",
}}
/>
{/* Layer 2: White glass substrate base */}
<div className="absolute inset-0 z-10" style={{ background: "rgba(255, 255, 255, 0.25)" }} />
{/* Layer 3: Mirror specular inset highlight limits */}
<div
className="absolute inset-0 z-20 rounded-3xl"
style={{
boxShadow: "inset 2px 2px 1px 0 rgba(255,255,255,0.5), inset -1px -1px 1px 1px rgba(255,255,255,0.5)"
}}
/>
{/* Layer 4: Interactive human content space */}
<div className="relative z-30">{children}</div>
</div>
);
};4. Designing a reactive floating menu dock
A responsive dock is super fun to use. By putting icons inside our glass component, we can make them scale up slightly (by 10%) when your mouse moves over them. The glass frame itself gently expands and rounds its edges as you hover, creating a smooth tactile feedback loop.
const GlassDock = ({ icons }) => {
return (
<GlassEffect className="rounded-3xl p-3 hover:p-4 hover:rounded-4xl">
<div className="flex items-center justify-center gap-2 rounded-3xl p-3 py-0 px-0.5 overflow-hidden">
{icons.map((icon, index) => (
<img
key={index}
src={icon.src}
alt={icon.alt}
className="w-16 h-16 transition-all duration-700 hover:scale-110 cursor-pointer"
style={{
transformOrigin: "center center",
transitionTimingFunction: "cubic-bezier(0.175, 0.885, 0.32, 2.2)"
}}
/>
))}
</div>
</GlassEffect>
);
};5. Bouncy buttons that feel incredibly springy
Standard animations look stiff and mechanical. Instead, you can use built-in cushion values (known as custom bezier curves) to make elements overshoot and bounce back slightly when scaled. It behaves exactly like compression physics, giving buttons a super playful and satisfying bounce when hovered or tapped.
const GlassButton = ({ children }) => {
return (
<GlassEffect className="rounded-3xl px-10 py-6 hover:px-11 hover:py-7 hover:rounded-4xl overflow-hidden">
<div
className="transition-all duration-700 hover:scale-95"
style={{
transitionTimingFunction: "cubic-bezier(0.175, 0.885, 0.32, 2.2)"
}}
>
{children}
</div>
</GlassEffect>
);
};