CSS glassmorphism and neumorphism: how to build both, and when not to
Glassmorphism and neumorphism are two popular interface styles. One looks like frosted glass floating above a background, the other like soft shapes pushed out of the page. Both are easy to build, and both are easy to overdo.
Glassmorphism: the idea
A semi-transparent panel sits over a colourful background, and the area behind it is blurred. The panel gets a thin light border so it looks like the edge of a sheet of glass. The CSS needs only a few lines:
.glass {
background: rgba(255, 255, 255, 0.2);
-webkit-backdrop-filter: blur(12px);
backdrop-filter: blur(12px);
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 16px;
}Making glass work
- Put something colourful behind it. Over a flat colour the blur has nothing to blur and the effect disappears.
- Keep the tint low, usually 10 to 30 percent opacity, so the background shows through.
- The backdrop-filter property works in current browsers. The -webkit- prefix helps older Safari.
- Use blur on small areas such as cards and menus. Large blurred areas can slow down weak devices.
Neumorphism: the idea
Neumorphism, short for new skeuomorphism, makes elements look moulded from the page itself. The element and the page share the same colour, and two shadows create the illusion: a dark one on one side and a light one on the other.
.card {
background: #e0e5ec;
border-radius: 20px;
box-shadow: 10px 10px 20px #bec3c9, -10px -10px 20px #e5e9ef;
}Getting the shadows right
- Use exactly the same colour for the page background and the element.
- The dark shadow is a darker shade of that colour and the light shadow a lighter one.
- For a pressed-in look, such as an active button, add the inset keyword to both shadows.
- On dark surfaces the highlight is hard to see, so use a bigger distance and stronger intensity.
The accessibility problem
Both styles rely on low contrast. Soft shadows make it hard for people with low vision to see where a button ends, and text over a blurred, changing background can be hard to read.
Check the contrast of text with a contrast checker. The WCAG guidelines ask for a ratio of at least 4.5 to 1 for normal text. Add clear labels, icons or borders to important controls, and do not rely on shadow alone.
When to use them
- Glass suits overlays, navigation bars and cards on top of photos or gradients.
- Neumorphism suits decorative widgets such as a music player or a dashboard dial.
- For forms, checkout buttons and anything that must be easy to use, choose clear, high-contrast design.
Generate the code
The glassmorphism generator and the neumorphism generator let you adjust blur, colour, distance and shape with a live preview, then copy the CSS. The box shadow generator is handy for fine-tuning a single shadow.