--- name: liquid-glass-web description: Build refractive "liquid glass" UI for the web (Apple Liquid Glass style) that renders the same in Chrome, Safari/iOS and Firefox — SVG feDisplacementMap applied through CSS filter to the content itself, runtime displacement maps, chromatic fringe and rim highlights, press/squish springs, WebKit-specific fixes, WebGL for video. Ships the liquidglass.dev web components (switch, slider, segmented, button, panel, navbar, menu bar, toast, dock, lens), the zero-dependency engine, a reference page and a three-engine screenshot script. Use whenever a web or front-end task (HTML/CSS/React/Vue/Svelte) asks for liquid glass, glass refraction, a glass lens or magnifier, glassmorphism that should actually bend light, or Apple-style glass switches, sliders, segmented controls, tab indicators, cards, navbars, menus, toasts or docks — and when a backdrop-filter glass effect does not show up in Safari or Firefox. Not for native SwiftUI/UIKit apps (use the system glassEffect there). --- # Liquid glass for the web Goal: glass that really bends light, like Apple's Liquid Glass, rather than a blur — and looks the same in Chromium, WebKit (Safari and every iOS browser) and Gecko (Firefox). The approach follows Aave Labs' [Building Glass for the Web](https://aave.com/design/building-glass-for-the-web); the bundled code is an independent implementation, verified screenshot-by-screenshot in all three engines. Live site and docs: https://liquidglass.dev. ## How it works 1. **Refraction goes on `filter: url(#id)`, not `backdrop-filter`.** `backdrop-filter: url()` only renders in Chromium. A plain `filter` referencing an SVG filter works everywhere, but it bends the element's *own* pixels — so whatever should be bent must be inside the glass element: the real content, or a decorative copy of it. 2. **The displacement map is generated at runtime from the lens shape.** Red/green = horizontal/vertical bend, blue = rim highlight, alpha = lens coverage, neutral grey 128 outside the lens. Pixels outside the lens pass through untouched, so text stays selectable and links clickable. 3. **Moving is cheap, reshaping regenerates.** Moving a lens only changes filter sub-region coordinates; the map is redrawn only when shape or optics change (cached, only a quarter computed). 4. **Surfaces without live DOM use WebGL with the same map.** Safari never runs SVG filters on a playing `