Skip to content

CSS Glassmorphism Generator

Set the tint, blur and saturation of a frosted-glass panel, drag it over a busy background or your own image, and see whether its text stays readable. Copy the CSS with fallbacks, or the Tailwind classes.

Frosted glass

Drag me over light and dark parts of the background.

Checking the contrast under the panel…

.glass {
  background: rgb(15 23 42 / 0.2);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgb(255 255 255 / 0.3);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgb(15 23 42 / 0.25), inset 0 1px 0 rgb(255 255 255 / 0.4);
  color: #FFFFFF;
}

/* No backdrop-filter support: a more solid background keeps the text readable */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass {
    background: rgb(15 23 42 / 0.9);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .glass {
    background: rgb(15 23 42 / 0.9);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

The fallback opacity (90%) is what this text needs over the unblurred background under the panel.

The four parts of a glass panel

What each part of the glassmorphism CSS does
PartCSSWhat it does
Tintbackground: rgb(255 255 255 / 0.2)A see-through colour; the opacity decides how much of the background shows and how readable the text is
Frostbackdrop-filter: blur(16px)Blurs whatever is behind the panel, so detail turns into soft colour
Colour boostsaturate(140%)Added to the same filter; keeps the blurred colours vivid instead of greyish
Edgeborder: 1px solid rgb(255 255 255 / 0.3)A faint light line that separates the panel from a similar background

The drop shadow and the light line along the top (inset 0 1px 0) are optional finishing touches. Everything here except backdrop-filter works without it, which is what makes the fallback below possible.

What backdrop-filter actually blurs

  • Only what is behind the panel, inside its border box. The result is clipped to the panel, including its rounded corners. Its own text and children are drawn on top, sharp.
  • It needs something to blur. Over a flat colour or a smooth gradient there is nothing to soften, and the panel just looks like a tinted box. Glass shows best over photos, shapes and text, which is why the backgrounds here have sharp detail.
  • It needs a see-through background. A fully opaque background hides the filtered backdrop completely.
  • Edges are mirrored. The blur reflects the content at the panel's edge rather than fading to black, so there is no dark rim.
  • opacity on the panel fades the blurred backdrop too, not only the panel. Use the background's alpha for transparency instead.

Keeping text readable on glass

The colour behind the text is the tint mixed with whatever is underneath, so contrast changes as the panel moves or the page scrolls. The checker reads the pixels under the panel, blurs and saturates them as the browser does, mixes in the tint and reports the worst spot against the 4.5:1 that WCAG asks for normal text.

Blur fixes some problems and not others. For a 280 × 160 panel in the middle of the Night background, with a navy #0F172A tint and white text:

Tint opacity needed for 4.5:1 over the Night background (saturate 140%)
BlurLowest contrast at 18% tintOpacity needed for 4.5:1
None2.78:141%
8px5.12:111%
16px5.19:110%
32px5.30:19%

Without blur, the thin white ring and the dot grid sit right behind the letters. Even 8px of blur smears them into the dark background, and the contrast almost doubles. Past that, more blur changes little. Blur cannot darken a large bright area, though. Move the same navy panel with white text over the Daylight background and it needs 57% opacity. Swap to an 18% white tint with dark text there and you get 7.63:1 without raising the opacity at all. If the page under a panel can be anything, such as user photos, plan for its brightest part or make the tint more solid.

Browser support and fallbacks

Support for backdrop-filter and the reduced transparency setting
FeatureChromeEdgeFirefoxSafari
backdrop-filter767910318; 9–17 need -webkit-backdrop-filter
prefers-reduced-transparency118118Behind a settingNo

The output keeps the -webkit- line for Safari and iOS before version 18. In a browser without either, the panel is just the tint, so the @supports not (…) block swaps in a more solid background, using the opacity the text needs over the unblurred background.

prefers-reduced-transparency: reduce matches when someone has asked their system for fewer see-through surfaces, for example on Windows with transparency effects turned off. The output gives those people the solid version. Where the query is not supported, the rule is simply ignored.

Glass inside glass

A glass panel can only blur content up to its nearest "backdrop root". In the current draft specification, these ancestors form one:

  • the page's root element
  • anything with filter, opacity below 1, mask, clip-path, backdrop-filter or a mix-blend-mode other than normal
  • anything with will-change naming one of those properties

So a glass button inside a glass card blurs only the card, not the page behind it, and a glass panel inside a parent that is fading in with opacity can look flat until the fade ends. z-index, transform and sticky or fixed positioning do not form a backdrop root. The draft is still being discussed, so browsers can differ here.

Glassmorphism in Tailwind

The Tailwind tab writes the same panel as utility classes. It uses a named blur when yours matches one, and Tailwind v4 accepts any number in backdrop-saturate-140. Tailwind adds no fallback, so add the @supports block from the CSS tab to your stylesheet if you need one.

Tailwind v4 backdrop-blur utilities
ClassBlurTailwind v3 name
backdrop-blur-xs4pxbackdrop-blur-sm
backdrop-blur-sm8pxbackdrop-blur
backdrop-blur-md12pxbackdrop-blur-md
backdrop-blur-lg16pxbackdrop-blur-lg
backdrop-blur-xl24pxbackdrop-blur-xl
backdrop-blur-2xl40pxbackdrop-blur-2xl
backdrop-blur-3xl64pxbackdrop-blur-3xl

When the glass does not look like glass

Common glassmorphism problems
SymptomCauseFix
Just a tinted box, no frostNothing detailed behind it, or the background is opaqueLower the opacity; put it over an image or shapes
No blur in SafariSafari before 18 only knows the prefixed propertyKeep -webkit-backdrop-filter
Blur only shows part of the pageAn ancestor is a backdrop root (opacity, filter, mask…)Move the effect off that ancestor
Fixed menu or modal inside is misplacedbackdrop-filter makes the panel their containing blockRender it outside, or put the filter on ::before
Looks grey and dullBlur averages colours toward greyRaise saturation to 140–180%
Edge disappears on light backgroundsA white edge on whiteUse a dark edge at low opacity
Scrolling stuttersA large blurred area over moving contentSmaller blur, smaller area, no animated blur

Frequently asked questions

What is glassmorphism?

A style where panels look like frosted glass: see-through, blurring what is behind them, with a light edge. In CSS it is a translucent background plus backdrop-filter: blur().

Does glassmorphism work in Firefox?

Yes, Firefox has supported backdrop-filter by default since version 103. Chrome has since 76 and Safari since 9 with the -webkit- prefix.

Do I still need -webkit-backdrop-filter?

Only for Safari and iOS before 18. It does no harm in other browsers, so most sites keep it.

What is the difference between filter: blur() and backdrop-filter: blur()?

filter blurs the element itself, text included. backdrop-filter blurs what is behind the element and leaves its own content sharp.

Why is my glass panel not blurring the background image?

Check that the image is behind the panel in the page (not a background of the panel itself), that the panel background is see-through, and that no ancestor has opacity, filter or a mask.

How much blur should I use?

Around 8–16px for cards and 12–20px for headers. A little blur clears fine detail from behind the text, but past about 8px, as the table above shows, extra blur adds little contrast.

Sources