How to create a glassmorphism effect
- Pick a background. Glass only looks like glass when there is something colorful behind it.
- Adjust blur to frost the background and transparency to control how much color shows through.
- Raise saturation to make the colors behind the glass richer, and add a thin light border to catch the edge.
- Copy the CSS and apply the
.glassclass to a card, navbar or dialog.
How the CSS works
background: rgba(255, 255, 255, 0.2)makes the element semi-transparent.backdrop-filter: blur(12px) saturate(160%)blurs and boosts whatever is behind the element, not the element itself.-webkit-backdrop-filteris still needed for Safari.- A
1pxsemi-transparent white border and a soft shadow separate the panel from the background.
Accessibility and performance tips
- Text on glass changes contrast as the background moves. Keep the panel opaque enough and check the result with the contrast checker against the lightest and darkest area behind it.
- Backdrop filters are GPU work. Use them on a few large surfaces, not on hundreds of list items, and avoid animating the blur.
- Provide a fallback background for users who turn on reduced transparency:
@media (prefers-reduced-transparency: reduce). - A dark glass (black at 20–40%) works well for overlays and media controls; a light glass suits cards and navbars.
Pair the effect with gradients from the CSS gradient generator and soft shadows from the box shadow generator.