Glassmorphism CSS: How to Create Glass Effect UI

Implement glassmorphism with backdrop-filter, rgba transparency, and border tricks. Includes browser support and accessibility.

6 min read CSS · Design · UI 6 sections + FAQ

Glassmorphism became one of the defining UI trends of the early 2020s. The frosted glass effect creates a sense of depth and translucency that feels modern and premium. Apple popularized it in macOS Big Sur, and it spread across web interfaces.

The CSS implementation requires three ingredients: backdrop-filter for the blur, rgba for transparency, and a semi-transparent border. The effect only works when there is something colorful behind the element to blur.

What is glassmorphism

Glassmorphism is a design style characterized by translucent surfaces with a frosted glass effect. Key visual properties: background transparency (30-50% opacity), background blur (8-32px), subtle border (1-2px, semi-transparent white), and soft drop shadow. The style creates a layered, depth-rich interface that feels light and airy.

Free Tool Glassmorphism Generator Create frosted glass UI effects with live CSS preview

backdrop-filter: blur() syntax

backdrop-filter applies graphical effects to the content behind an element. The blur() function blurs the background: backdrop-filter: blur(12px). Higher values create more blur. Unlike filter: blur() which blurs the element itself, backdrop-filter blurs everything behind the element through its transparent areas. It requires the element to have some transparency to see the effect.

rgba and transparency

The glass surface uses rgba() for the background color with low alpha: background: rgba(255, 255, 255, 0.15). For dark glass: rgba(0, 0, 0, 0.2). The alpha value (0.15-0.25) controls how transparent the surface is. Too high and the background shows through too much. Too low and the glass effect is not visible. White-based glass works on colorful backgrounds. Adjust the base color to match your design.

Free Tool CSS Filter Generator Apply blur, brightness, contrast and more with CSS filters

Border with rgba

A defining characteristic of glassmorphism is the semi-transparent border that catches light. Use: border: 1px solid rgba(255, 255, 255, 0.3). For dark themes: border: 1px solid rgba(255, 255, 255, 0.1). The border simulates light reflecting off the edge of glass. Combining border with a subtle box-shadow adds to the three-dimensional illusion.

Browser support and fallbacks

backdrop-filter is supported in all modern browsers since 2022 (Chrome, Firefox, Safari, Edge). Firefox required the -webkit- prefix until version 103. For older browsers, provide a fallback with a solid or slightly transparent background. Use CSS feature detection: @supports (backdrop-filter: blur(1px)) to apply glassmorphism only where supported.

Performance considerations

backdrop-filter is expensive — it triggers compositing and can hurt performance on complex pages or mobile devices. Performance tips: limit the number of elements with backdrop-filter, avoid animating backdrop-filter if possible, test on low-end devices, and use will-change: backdrop-filter on elements that will animate. Accessibility warning: blurred backgrounds can reduce readability for users with visual impairments.

Free Tool Neumorphism Generator Create soft UI extruded effects with dual box shadows

Frequently Asked Questions

What is the minimum CSS for a glassmorphism effect? +
Three properties: background: rgba(255,255,255,0.15); backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,0.3). Plus a colorful background behind the element.
Why does my backdrop-filter not work? +
Most common reasons: the element is fully opaque (no transparency), there is no content behind the element, or the browser does not support backdrop-filter. Check browser support and ensure the element has rgba background.
Does glassmorphism have accessibility issues? +
Yes. Blurred backgrounds reduce text readability. Always ensure sufficient contrast ratio between text and the blurred background surface. Avoid using light text on blurred colorful backgrounds without a solid text shadow.
Can I use glassmorphism on dark backgrounds? +
Yes. For dark glass: background: rgba(0,0,0,0.2); backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,0.1). Dark glass works well on dark colorful gradients.
How do I add a fallback for browsers without backdrop-filter support? +
Use @supports: @supports (backdrop-filter: blur(1px)) for the glass effect, and outside it provide a solid or less transparent background as fallback.
What blur value should I use for glassmorphism? +
Typical values: 8px for subtle glass, 12-16px for standard glass, 24-32px for heavy frosted glass. Higher values are more visually striking but more expensive for rendering.
Is glassmorphism still a current design trend? +
Glassmorphism peaked in 2021-2022 and has settled into mainstream use for specific contexts: cards, overlays, and modals. Used selectively, it still looks modern and premium. Overused, it becomes dated.