Notes

Glass you can still read

29 October 2026 2 min read

Frosted glass looks great on a mockup and fails on a busy background. Drag a panel over a loud backdrop and watch the contrast being measured from real pixels.

  • Visual design
  • Accessibility
  • Canvas

Glass is everywhere: blurred panels, soft edges, a hint of light. In a design file it sits on a calm background and everything reads. In the product it sits on whatever the user has behind it.

Drag the glass over the backdrop

Payment confirmed

Your order ships tomorrow. We will send tracking by e-mail.

Worst contrast under the text
0.0:1 fails AA (4.5:1)

Live demo. Everything runs in your browser. Now try to break it.
GlassContrast.svelte, 213 lines

The backdrop is loud on purpose: hard white stripes, a yellow circle, a near-black one. Drag the panel over them. The number below is the worst contrast ratio of any pixel under the text, measured from the pixels that are actually drawn.

What to try

Start with "Looks great": a little blur, a little tint. Move the panel onto a stripe or the yellow circle. The ratio drops and the label flips to fail. Now press "Readable" and move it again. It is less pretty and it holds.

Blur alone does less than it seems to. It softens edges but the average colour under the text stays whatever the background is. A white stripe blurred is still light, and dark text on light is fine, but dark text on a blurred patch of purple is not. The tint is what sets a floor.

The rule behind it

Contrast is a ratio of the lightest and the darkest colour involved. For text the check has to hold at the worst point under it, not at the average and not on the screenshot in the design file. That is why the demo reports the minimum.

// luminance of a pixel, then the WCAG ratio against the text colour
const L = lum(r, g, b);
const ratio = (Math.max(L, Lt) + 0.05) / (Math.min(L, Lt) + 0.05);
worst = Math.min(worst, ratio);

What to do in a real product

  • Put a tint under every glass panel that carries text, and choose it for the worst background you ship, not the nicest.
  • Test over the loudest content you have: a photo, a video, a banner with a sale.
  • Offer a solid fallback. Many systems have a setting for reduced transparency, and prefers-reduced-transparency is how a page can listen to it.
  • Keep text on glass short. Long reading belongs on a solid surface.

A note on the demo

The glass is drawn on a canvas, which is what makes the measurement possible. In a real page you would use backdrop-filter, and you cannot read back what it paints. That is the practical problem with glass: the browser will not tell you the contrast, so you have to design for the worst case.

Related

How bright was it?

Five lamps and an optional line. Feedback, a bug, an idea, anything. I read every one and sum them up once a month.

Pick a lamp

Stored without name, address or cookie, and deleted after a year. Details in the privacy notice.