Everything below is the CSS running on this site today. The glass itself is plain CSS, and the only script is a small pointer listener that moves a highlight.
Apple introduced Liquid Glass at WWDC25 as the new material across its platforms. In the Meet Liquid Glass session, the design team describes lensing that bends and concentrates light, highlights that respond to shape and motion, and shadows that adapt to the content underneath.
This portfolio uses a CSS version of that material for the navbar, the footer, project cards and buttons. The page is near black with white text, which is the hardest background glass can get. Below is how it's built, with code from styles/globals.css, and what I'd want to know before copying it.
Why glass on black looks like nothing
backdrop-filter: blur() averages the pixels behind an element. Average a patch of black and you get black. A glass panel on a #000 page shows its border and nothing else, and you pay for a blur that has nothing to work with.
Apple's glass always sits over a wallpaper or app content. A dark site has to supply that light itself. Here it's one fixed element in the layout:
<div aria-hidden="true" className="ambient-backdrop" />
<GlassPointer />.ambient-backdrop {
position: fixed;
inset: 0;
z-index: -1;
pointer-events: none;
background:
radial-gradient(60vw 55vh at 10% 6%, rgb(64 104 255 / 0.3), transparent 70%),
radial-gradient(48vw 48vh at 94% 20%, rgb(146 96 255 / 0.24), transparent 70%),
radial-gradient(56vw 50vh at 80% 92%, rgb(30 190 235 / 0.16), transparent 70%),
radial-gradient(42vw 40vh at 4% 82%, rgb(255 120 92 / 0.1), transparent 70%),
#030408;
}
/* film grain keeps the large gradients from banding */
.ambient-backdrop::after {
content: "";
position: absolute;
inset: 0;
opacity: 0.08;
background-image: url("data:image/svg+xml,..."); /* 160px feTurbulence tile */
}Four large, faint blobs sit near the corners over an almost black base. The page still reads as black, but every glass surface now has some coloured light behind it. Gradients this big and this faint tend to band, so ::after adds an SVG noise tile at 8% opacity to dither them.
The fixed layer needs a transparent body. When both html and body have a background, the body's background is painted over anything with a negative z-index, so globals.css keeps background: #000 on html and sets body to transparent.
Where a section needs more colour, decoration goes directly behind the glass. The call-to-action places two GlassOrb SVGs from components/v3/shared/Decor.tsx under its panel:
// The orbs sit behind the glass panel on purpose: the blur refracts them.
<section className="relative isolate px-5 py-16 sm:px-6 lg:py-24">
<GlassOrb
hue="violet"
className="pointer-events-none absolute top-4 right-[8%] -z-10 h-56 w-56 sm:h-72 sm:w-72"
/>
<GlassOrb
hue="cyan"
className="pointer-events-none absolute bottom-6 left-[6%] -z-10 h-40 w-40 sm:h-52 sm:w-52"
/>
<div className="liquid-glass mx-auto max-w-[1120px] rounded-[32px] px-6 py-12 sm:px-12 sm:py-16">
{/* ... */}
</div>
</section>GlassOrb is plain SVG: a radial gradient body, a gradient rim and two blurred white reflections. Its gradient ids come from useId(), so two orbs on one page never share a url(#...) reference. Under the panel's 18px blur they become soft patches of colour.
The layer stack
In paint order, from the bottom up:
| Layer | Where it lives | What it does |
|---|---|---|
| Ambient light | .ambient-backdrop | Gives the blur colour to work with |
| Depth | outer box-shadow | Contact shadow and lift, outside the box |
| Backdrop | backdrop-filter on the element | Blurs, saturates and brightens what's behind |
| Tint and sheen | background on the element | 5.5% white fill plus a top-down gradient |
| Bevel | inset box-shadow | Brighter edges as a stand-in for lensing |
| Pointer glow | ::after, z-index: -1 | Soft radial light that follows the cursor |
| Specular rim | ::before, z-index: 2 | 1px gradient ring above the content, brightest top-left |
Most of it sits on the element itself:
.liquid-glass,
.liquid-glass-strong {
--glass-fill: rgb(255 255 255 / 0.055);
--glass-blur: 18px;
--glass-saturate: 180%;
--glass-brightness: 1.1;
position: relative;
isolation: isolate;
overflow: hidden;
background:
linear-gradient(180deg, rgb(255 255 255 / 0.07), rgb(255 255 255 / 0) 55%),
var(--glass-fill);
-webkit-backdrop-filter: blur(var(--glass-blur))
saturate(var(--glass-saturate)) brightness(var(--glass-brightness));
backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate))
brightness(var(--glass-brightness));
box-shadow:
inset 0 1px 0 rgb(255 255 255 / 0.18),
inset 0 -1px 0 rgb(255 255 255 / 0.05),
inset 0 10px 22px -16px rgb(255 255 255 / 0.22),
inset 0 -14px 24px -20px rgb(255 255 255 / 0.12),
0 1px 2px rgb(0 0 0 / 0.35),
0 18px 48px -18px rgb(0 0 0 / 0.7);
}isolation: isolate makes each surface its own stacking context, so the glow with z-index: -1 paints above the element's background and below its text. overflow: hidden clips both pseudo-elements to the radius.
Both backdrop-filter spellings are there on purpose. WebKit only added the unprefixed property in Safari 18, so older Safari and iOS versions need -webkit-. Neither spelling gets around WebKit bug 297620, which is still open: Safari on macOS Sonoma doesn't apply backdrop-filter when the value references a CSS variable. These tokens are written exactly that way, so on Sonoma the panels most likely render without blur.
The fill is tiny because a stronger white tint on black starts to look like grey plastic to me. To tint a surface, override the token with something like [--glass-fill:rgb(66_141_255/0.12)]. A Tailwind bg-* utility sits in a later cascade layer than @layer components, so it replaces the whole layered background and takes the sheen with it.
saturate(180%) and the other numbers
Blur mixes neighbouring colours, and mixing drags everything toward grey. With colour coming only from faint blobs, blur alone gives a dull smudge, and saturate(180%) pushes the colour back. Apple uses the same value on its own site: the apple.com global navigation sets saturate(180%) blur(20px) (globalheader.css). Pavel's write-up of six ways to build Liquid Glass calls saturate(180%) "the whole trick" for the same reason. brightness(1.1) lifts the dim ambient light so the glass reads lighter than the page.
A strong variant is there for menus and modals, where text has to stay readable over whatever scrolls past:
.liquid-glass-strong {
/* fill alone keeps white text >= 6.7:1 over a white backdrop (sheen + glow lower the worst case to ~4.9:1) */
--glass-fill: rgb(14 15 20 / 0.68);
--glass-blur: 24px;
--glass-saturate: 160%;
--glass-brightness: 1;
}The alpha comes from the WCAG contrast formula, applied after the saturate and brightness matrices. At 0.68 the fill alone keeps white text at 6.7:1 even over a pure white backdrop; with the top sheen and the pointer glow added, the worst spot mid-panel drops to about 4.9:1, still above the minimum. At 0.55 the same calculation gives 4.2:1, which is under the 4.5:1 minimum for body text. Brightness goes back to 1 so it doesn't eat into that margin. For comparison, Apple's dark nav in the same stylesheet uses rgba(22,22,23,.8).
The variant only works because the var() calls are composed on the component selector. A token like --glass-filter: blur(var(--glass-blur)) declared on :root resolves there and is inherited as a finished value, so a variant that overrides --glass-blur would change nothing.
A specular rim from a masked gradient
To my eye, most of the Liquid Glass look comes from the bright, uneven edge. Here it's a 1px gradient ring on ::before:
.liquid-glass::before {
content: "";
position: absolute;
inset: 0;
z-index: 2;
border-radius: inherit;
padding: 1px;
background: linear-gradient(
135deg,
rgb(255 255 255 / 0.55),
rgb(255 255 255 / 0.12) 26%,
rgb(255 255 255 / 0.03) 52%,
rgb(255 255 255 / 0.14) 80%,
rgb(255 255 255 / 0.32)
);
-webkit-mask:
linear-gradient(#000 0 0) content-box,
linear-gradient(#000 0 0);
-webkit-mask-composite: xor;
mask:
linear-gradient(#000 0 0) content-box exclude,
linear-gradient(#000 0 0);
pointer-events: none;
}The mask has two layers, one painted only in the content box and one over the full box. exclude keeps the pixels where exactly one of them is opaque, which leaves the 1px of padding as a ring. The gradient underneath becomes a border that follows border-radius.
The 135deg gradient puts the strongest light at the top-left, fades to almost nothing through the middle and picks up a weaker catch at the bottom-right, like light reflecting inside a thick slab. mask-composite has been Baseline since 2023, and Lightning CSS (which Tailwind v4 uses) generates the -webkit-mask-composite fallback by itself, so the hand-written -webkit- lines are optional here.
Fake lensing with inset shadows
Real Liquid Glass bends the background near its edges. No cross-browser CSS can refract the backdrop, so four inset shadows imitate the result. A 1px lip at the top (18% white) and a fainter one at the bottom (5%) mark the edges. Under the top lip, inset 0 10px 22px -16px adds a soft falloff, and inset 0 -14px 24px -20px brings a weaker glow up from the bottom. The edges end up thicker and brighter than the middle, which is roughly what a lens does to light.
The two outer shadows add contact and lift. On black they only show where ambient light sits behind the surface, which fits how Apple's shadows adapt to what's underneath.
A sheen that follows the pointer
The ::after layer is a large radial gradient centred on two custom properties:
.liquid-glass::after {
content: "";
position: absolute;
inset: 0;
z-index: -1;
border-radius: inherit;
background: radial-gradient(
circle 22rem at var(--glass-x, 25%) var(--glass-y, -30%),
rgb(255 255 255 / 0.13),
transparent 70%
);
pointer-events: none;
}Before the pointer arrives, the fallback position puts a faint glow along the top edge, left of centre. GlassPointer, mounted once in the layout, moves it:
useEffect(() => {
if (!window.matchMedia("(hover: hover)").matches) return;
let frame = 0;
let last: PointerEvent | null = null;
const update = () => {
frame = 0;
const target = last?.target;
if (!last || !(target instanceof Element)) return;
const glass = target.closest<HTMLElement>(".liquid-glass, .liquid-glass-strong");
if (!glass) return;
const rect = glass.getBoundingClientRect();
glass.style.setProperty("--glass-x", `${last.clientX - rect.left}px`);
glass.style.setProperty("--glass-y", `${last.clientY - rect.top}px`);
};
const onMove = (event: PointerEvent) => {
last = event;
if (!frame) frame = requestAnimationFrame(update);
};
document.addEventListener("pointermove", onMove, { passive: true });
return () => {
document.removeEventListener("pointermove", onMove);
cancelAnimationFrame(frame);
};
}, []);One passive listener covers the whole document. Each event only replaces last, and the layout read and style writes happen at most once per frame. Touch devices fail the (hover: hover) check and skip it, so a tap never leaves a stray glow behind.
The script never resets the properties, so a surface keeps its highlight where the pointer left it. I prefer that to a glow that snaps back.
The backdrop-root trap
Filter Effects Level 2 defines a Backdrop Root: a backdrop filter only sees content painted inside the nearest ancestor that forms one. Triggers include a filter other than none, opacity below 1, mask or clip-path, another backdrop-filter, a non-normal mix-blend-mode, and will-change naming any of those. In Chrome, view-transition-name on an ancestor breaks the blur too. Transforms, z-index and fixed or sticky positioning are safe, and the spec says so explicitly.
The ambient layer sits outside every section, so when an ancestor becomes a backdrop root, the glass inside it stops seeing the coloured light and goes flat.
In React, the trap I'd watch for is a framer-motion "blur in" reveal. Animating from filter: "blur(8px)" to filter: "blur(0px)" leaves filter: blur(0px) inline on the wrapper. That still counts as a filter, so every glass element inside stays broken for good. The Reveal component on the home page animates only opacity and position:
// No filter animation: a filter on an ancestor breaks descendants' backdrop-filter.
<m.div
className={className}
initial={{ opacity: 0, y: 28 }}
transition={{ delay, duration: 0.72, ease: [0.16, 1, 0.3, 1] }}
viewport={{ amount: 0.18, margin: "0px 0px -90px 0px", once: true }}
whileInView={{ opacity: 1, y: 0 }}
>
{children}
</m.div>Opacity is a trigger too. While the fade runs, the wrapper is a backdrop root and glass inside it blurs only the wrapper's own content. The animation ends at opacity: 1, which isn't a trigger, so the full effect switches on when the 0.72s reveal finishes. If a glass element must look right during its entrance, put the opacity animation on the glass element itself, since an element's own opacity only fades its already-filtered result.
The same rule decides where the blur lives. With backdrop-filter on a ::before layer, any opacity on the element makes it a backdrop root for its own pseudo-element, and a fade-in shows no blur until it reaches 1.
Glass inside glass gets its backdrop pass switched off:
/* glass on glass: the parent already blurred the page, skip the second pass */
:is(.liquid-glass, .liquid-glass-strong) :is(.liquid-glass, .liquid-glass-strong) {
-webkit-backdrop-filter: none;
backdrop-filter: none;
}The parent's backdrop-filter makes it a backdrop root anyway, so a nested blur would only see the parent's content. Nested backdrop filters also differ between engines (WebKit bug 280531 is one example). The tech tags inside the project card rely on this rule.
backdrop-filter also creates a containing block for position: fixed descendants. A fixed dropdown or mobile menu inside a glass navbar gets trapped in the navbar's box. Render it through a portal.
Fallbacks
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
.liquid-glass,
.liquid-glass-strong {
--glass-fill: rgb(26 28 38 / 0.94);
}
}
@media (prefers-reduced-transparency: reduce) {
.liquid-glass,
.liquid-glass-strong {
--glass-fill: rgb(22 24 32 / 0.97);
-webkit-backdrop-filter: none;
backdrop-filter: none;
}
}
@media (prefers-contrast: more) {
.liquid-glass::before,
.liquid-glass-strong::before {
background: rgb(255 255 255 / 0.6);
}
}Without backdrop-filter, a 5.5% white fill over black doesn't read as a surface, so the fallback swaps in a nearly opaque dark fill. Everything reads var(--glass-fill), so one token per block is enough.
prefers-reduced-transparency has worked in Chromium since Chrome 118. Safari doesn't support it: in WebKit neither reduce nor no-preference matches, so a Safari user with Reduce Transparency on still gets the default glass. The default has to be legible without the media query, which is why text-heavy floating UI belongs on the strong variant. Under prefers-contrast: more the rim becomes a solid 60% white line so every edge stays visible.
The performance budget
Pavel's article explains where the cost comes from. The compositor has to filter the area behind the element again whenever that area changes, so a panel over a still page is close to free and a blurred sticky header pays on every scroll frame. The ambient layer here doesn't animate, but scrolling still counts: cards move across the fixed light layer, so the area behind them changes on every scroll frame.
The rules I work to:
- Keep blur at or below 24px on large surfaces, and never cover the full viewport with glass. Cost grows with both blur radius and area.
- Aim for six to eight visible glass surfaces at most on mobile.
- If a surface only ever sits over pure black, turn its filter off. Blurring black gives black, so it looks the same and costs nothing.
- Skip progressive blur built from stacked layers. Pavel stopped seeing steps at seven layers, and 20 full-screen layers struggled on a mid-range Android phone.
- Test on a real mid-range Android phone and an iPhone in Low Power Mode. A fast laptop won't show these problems.
Why I skipped SVG displacement lensing
The closest you can get to Apple's refraction in a browser is an SVG filter with feDisplacementMap, referenced from backdrop-filter: url(#lens). Kube.io has a detailed walkthrough that builds the displacement maps from first principles, and its demos show real refraction at the edges.
GlassSurface lensing an image. Drag the lens, tap anywhere, or focus it and use the arrow keys. Chromium gets the real thing, an SVG displacement map in backdrop-filter: url(). Safari and Firefox get a WebGL copy that redraws this one known image, which wouldn't work over live page content; there they'd only get blur.Both kube.io and Pavel describe it as Chromium-only. The Firefox report about displacement in backdrop-filter (Mozilla bug 1808785) was closed as invalid, citing the spec's restrictions on feDisplacementMap. In Safari, CSS.supports('backdrop-filter', 'url(#f)') returns true, and then it draws no backdrop at all. @supports can't gate it, so you end up sniffing the engine, for example with navigator.userAgentData, which only Chromium exposes.
The map also has to match the element's pixel size, so every lensed element needs its own filter, rebuilt by a ResizeObserver whenever it resizes. The bend is clearest under a light blur of a few pixels, and on a text panel that lets the page text behind it show through and compete with the panel's own copy.
Pavel's article also suggests -apple-visual-effect: -apple-system-glass-material, saying iOS 26 Safari exposes the system material to the web. WebKit's changelog says the property isn't meant to be web-exposed, and CSS.supports returns false for it in a standard WKWebView, so I wouldn't ship it.
For a portfolio, that's a lot of engine-specific code for an effect Safari and Firefox visitors would never see. The previous iteration of this site rendered two static feDisplacementMap filters from the root layout with no engine check, and that component is gone in this version. If I add lensing later, I'd limit it to three or four small buttons in Chromium, on top of the CSS above.