Tutorials

How to Make a Glassmorphism Card with CSS (Copy-Paste Code)

What the frosted-glass effect is, what each line of its CSS does, how to build it with a live-preview generator, and the mistakes that make it unreadable.

ProTools Hub Team5 min read

What glassmorphism is

Glassmorphism is a user interface style that makes a card, panel or button look like frosted glass. The surface is partly transparent, the background behind it appears blurred, and a thin light border and soft shadow separate it from the page. It became popular in app and dashboard design because it adds depth without heavy graphics.

In CSS, the effect comes from a small group of properties. The key one is backdrop-filter, which applies a blur or colour effect to whatever is behind an element, not to the element's own content.

What we tested: the default frosted card

We used the free Glassmorphism Generator, which is part of a larger CSS generator suite. It shows a live preview of a card over a colourful background of purple, blue, orange and pink shapes, with presets named Frosted light, Dark glass, Subtle and Heavy blur. We left it on its default settings: a white glass tint at 25% opacity, a 12px blur, 180% saturation, a 20px corner radius and a white border colour.

The CSS tab produced this code for a class named element: a background of rgba(255, 255, 255, 0.25); a backdrop-filter of blur(12px) saturate(180%) and the same value with the -webkit- prefix; a border-radius of 20px; a border of 1px solid rgba(255, 255, 255, 0.3); and a box-shadow of 0 8px 32px rgba(0, 0, 0, 0.2). The HTML tab produced a div with the class element containing an h3 and a paragraph.

We did not test the four presets, other values or the other generators in the suite in this run, so the explanations below describe the default output only.

What each line of the CSS does

Here is the default output, one property at a time.

  • background: rgba(255, 255, 255, 0.25) paints a white layer at 25% opacity. This is the glass tint, and it is what lets the background show through.
  • backdrop-filter: blur(12px) saturate(180%) blurs what is behind the card by 12 pixels and boosts its colours, so the frosted area looks vivid and not washed out.
  • -webkit-backdrop-filter repeats the same effect with a prefix. Some Safari versions need it, and keeping both costs nothing.
  • border-radius: 20px rounds the corners.
  • border: 1px solid rgba(255, 255, 255, 0.3) draws a thin, light edge that catches the eye like the edge of real glass.
  • box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2) adds a soft shadow below the card to lift it from the background.

Step by step: building your card

Here is how to use the generator. Open the free [Glassmorphism Generator](/tools/glassmorphism-generator) to follow along.

  • Open the Glassmorphism Generator and pick it from the Effects list on the left, or start from a preset.
  • Adjust the settings: glass tint, tint opacity, blur, saturation, corner radius and border colour. The live preview updates as you move each slider.
  • Set the Class field to the name you use in your own stylesheet.
  • Open the CSS tab and click Copy CSS, then open the HTML tab and click Copy HTML for the matching markup.
  • Paste both into your project. Remember to put the card on top of a background with colour or an image, or the blur has nothing to show.

Why the background matters

Backdrop blur blurs what is behind the element. If the page behind it is a flat colour, there is nothing to blur, and the card simply looks like a faintly tinted rectangle. The effect works best over gradients, photos or shapes with several colours, as in the generator's preview. When you test your design, look at it over the real background it will use.

Common mistakes to avoid

Most problems with this style come from the same few causes.

  • Poor text contrast. Text over a translucent, blurred layer can be hard to read when the colours behind it change. Check contrast against the WCAG guideline of 4.5:1 for normal text, and raise the tint opacity or use darker text if needed.
  • Too much blur on large areas. Blurring is computed by the browser every time the content behind it changes, so a big blurred panel can feel sluggish on low-powered devices. Use a modest blur and keep glass areas small.
  • No fallback. If a browser does not support backdrop-filter, the card will be just a pale translucent box. Add a more opaque background inside an @supports not (backdrop-filter: blur(1px)) rule so the text stays readable.
  • Overuse. A screen full of glass panels loses the depth that made the effect attractive. Use it for one or two key surfaces.

Browser support

Current versions of the major browsers support backdrop-filter, but support has not always been universal and older or unprefixed versions behave differently, which is why the generator outputs the -webkit- version as well. Before you rely on the effect for something important, check a current compatibility table such as the one on MDN or Can I use, and test on the browsers your visitors actually use.

Try it free

Glassmorphism Generator

Adjust blur, tint and borders with a live preview, then copy the CSS and HTML.

Open tool

Frequently asked questions

What CSS property creates the frosted glass effect?

backdrop-filter, usually with blur(). It blurs whatever is behind the element, and a semi-transparent background colour provides the glass tint.

Why can I not see any blur on my card?

Either there is nothing colourful behind it, or the browser does not support backdrop-filter. Place the card over a gradient or image and check support.

Do I need the -webkit-backdrop-filter line?

It is safest to keep it. It costs nothing and helps with Safari versions that need the prefix.

Is glassmorphism bad for accessibility?

It can be if text contrast is low. Check contrast against the real background and increase the tint opacity or darken the text where needed.

Does the generator upload my settings?

The tool runs in your browser. The site itself uses analytics and advertising scripts, as described in our Privacy Policy.

Keep reading

Written by the ProTools Hub Team. This article is for general information. Features and browser support change over time, so check current documentation for anything critical.