Glassmorphism CSS: How to Create Glass Effect UI
Implement glassmorphism with backdrop-filter, rgba transparency, and border tricks. Includes browser support and accessibility.
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 previewbackdrop-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 filtersBorder 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