AI CSS Animations

Frosted Glass Panel

Heavy frosted glass with a fine grain, like sandblasted glass, over a slowly turning aurora. The grain is an inline SVG turbulence filter blended in with overlay, so text stays crisp.

Also known as: frosted glass css, frosted glass effect css, glass noise texture css.

Frosted glass

Readable over anything

A heavy blur, a little grain and a soft inner glow.

HTML

<div class="gls-frosted-glass-panel">
  <span class="gls-frosted-glass-panel-aurora" aria-hidden="true"></span>
  <article class="gls-frosted-glass-panel-pane">
    <svg class="gls-frosted-glass-panel-grain" aria-hidden="true" focusable="false">
      <filter id="gls-frosted-glass-panel-noise"><feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="3" stitchTiles="stitch"/><feColorMatrix type="saturate" values="0"/></filter>
      <rect width="100%" height="100%" filter="url(#gls-frosted-glass-panel-noise)"/>
    </svg>
    <p class="gls-frosted-glass-panel-kicker">Frosted glass</p>
    <h3 class="gls-frosted-glass-panel-title">Readable over anything</h3>
    <p class="gls-frosted-glass-panel-text">A heavy blur, a little grain and a soft inner glow.</p>
  </article>
</div>

CSS

.gls-frosted-glass-panel {
  --c: var(--gls-color, #3b82f6);
  font-size: var(--gls-size, 16px);
  position: relative;
  display: grid;
  place-items: center;
  width: 22em;
  height: 12em;
  border-radius: 1.25em;
  overflow: hidden;
  isolation: isolate;
  background: color-mix(in srgb, var(--c) 45%, #0f172a);
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.3;
}
.gls-frosted-glass-panel-aurora {
  position: absolute;
  inset: -40%;
  background:
    radial-gradient(closest-side at 32% 40%, color-mix(in srgb, var(--c) 90%, #fff), transparent),
    radial-gradient(closest-side at 68% 58%, #f472b6, transparent),
    radial-gradient(closest-side at 50% 30%, #facc15, transparent 80%),
    radial-gradient(closest-side at 40% 70%, #2dd4bf, transparent);
  animation: gls-frosted-glass-panel-turn 14s linear infinite;
}
.gls-frosted-glass-panel-pane {
  position: relative;
  overflow: hidden;
  width: 14em;
  padding: 1.1em 1.25em 1.2em;
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: 1.1em;
  background: rgb(255 255 255 / 0.16);
  -webkit-backdrop-filter: blur(1.5em) saturate(1.3);
  backdrop-filter: blur(1.5em) saturate(1.3);
  box-shadow: inset 0 0 1.6em rgb(255 255 255 / 0.14), inset 0 1px 0 rgb(255 255 255 / 0.5), 0 0.8em 2em -1em rgb(0 0 0 / 0.5);
}
.gls-frosted-glass-panel-grain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.35;
  mix-blend-mode: overlay;
  pointer-events: none;
}
.gls-frosted-glass-panel-kicker {
  position: relative;
  margin: 0;
  font-size: 0.6em;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.8;
}
.gls-frosted-glass-panel-title {
  position: relative;
  margin: 0.25em 0 0;
  font-size: 1.2em;
  font-weight: 750;
  letter-spacing: -0.01em;
}
.gls-frosted-glass-panel-text {
  position: relative;
  margin: 0.35em 0 0;
  font-size: 0.75em;
  color: rgb(255 255 255 / 0.85);
}
@keyframes gls-frosted-glass-panel-turn {
  to { transform: rotate(1turn); }
}

@media (prefers-reduced-motion: reduce) {
  .gls-frosted-glass-panel, .gls-frosted-glass-panel *, .gls-frosted-glass-panel::before, .gls-frosted-glass-panel::after, .gls-frosted-glass-panel *::before, .gls-frosted-glass-panel *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --gls-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --gls-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar glass effects