Skip to content
Animatio

Glass & surfaces

html
<nav class="an-glass an-glass-nav an-glass-noise">…</nav>

Blur, saturation, a specular top edge, a seated bottom edge, and a four-layer shadow. Every var() carries its fallback inline, because a bare var() with the token unset invalidates the whole box-shadow and you lose all four layers, not one.

Tokens

TokenDefault
--an-glass-blur16px
--an-glass-tint#fff
--an-glass-alpha12%
--an-glass-sat1.6
--an-glass-radius1rem

Variants: an-glass-sm|md|lg|xl, -dark, -frost, -card, -nav, -tooltip, -edge, -flat.

Grain

an-glass-noise is a real feTurbulence type="fractalNoise" — rendered to a data-URI background-image, not referenced as a filter. That distinction is the whole reason it works everywhere.

an-noise-fine and an-noise-coarse change the frequency.

Refraction — and why it is opt-in

backdrop-filter: url(#svgFilter) does not work. WebKit parses it and renders nothing (bug 245510); Chromium handles only some cases.

Worse, the obvious guard is actively harmful:

css
/* DO NOT DO THIS */
@supports (backdrop-filter: url("#an-refract")) { … }

@supports tests whether a declaration parses, not whether it renders. That query returns true in Safari and switches the broken path on. It looks safe and is not.

So refraction is explicit:

html
<html data-an-refract="on">
<div class="an-svg-glass-refract">…</div>

Set the attribute after your own render probe. Without it, the element is plain an-glass — visually good, just not refractive.

The SVG sprite

Classes prefixed an-svg-* need assets/animatio-filters.svg pasted into your page once:

html
<svg width="0" height="0" aria-hidden="true" style="position:absolute">
  <!-- contents of animatio-filters.svg -->
</svg>

The prefix is the install instruction, and check:svg-naming enforces that exceptionlessly in both directions: no filter: url() outside an an-svg-* class, and no referenced filter id missing from the sprite.

Gotchas

  • filter and backdrop-filter create a containing block. A position: fixed descendant becomes relative to the glass element, so dropdowns, popovers and modals inside glass break. This is the #1 support question for every glass library.
  • They also create a stacking context, so z-index inside behaves differently.
  • Nested glass double-blurs — an-glass-flat opts out of the backdrop.
  • feDisplacementMap over a live backdrop is the most expensive thing in the library. Cap it at ~2 per viewport.

Shadows

an-shadow-0an-shadow-6 are layered ambient-plus-direct scales tinted from --an-shadow-color (an HSL triplet, so it can inherit your brand hue). Plus an-shadow-glow, -inner, -crisp, -long, -neu, -colored, -lift.

MIT. Parity module derived from animate.css 4.1.1, © 2020 Animate.css.