Give a UI widget virtual mass, and it warps the space around it. Background pixels pull into arcs, and the page appears to bend along an active gravitational field.
Interacting with a widget adds mass, so the page bends around what you use.
Here for the demos? Skip the physics and jump straight to the live Music, Chat, and Weather prototypes.
Before you try it: This only works in Chromium browsers (Chrome, Edge, Arc). Safari, Firefox, and all iOS browsers don't yet support SVG filters inside backdrop-filter.
The physics: from starlight to pixels
Mass curves spacetime, and curved spacetime bends light.
We see this in deep space all the time: light from a distant galaxy bends around a heavy foreground cluster, stretching into an arc — or a full circle called an Einstein ring.
Why it matters: Bending light changes where things appear to be and stretches their shape. Every active widget does the same thing to the elements behind it.
Starlight grazing the Sun's edge bends by 1.75 arcseconds — about 1/2000 of a degree — first measured during the 1919 solar eclipse. Across cosmic distances, even a tiny angle shifts where a star appears in the sky.
The lens equation
The gravitational lens equation connects where a background star appears to be (θ) to where it actually is (β):
θ(theta): Where the star appears to be, measured as an angle from the lens centre.β(beta): Where the star actually is.θE(theta-E): The Einstein radius, which grows with the square root of the lens's mass.
In other words: Gravity pulls passing light inward, which makes the background image look pushed outward. Objects behind the mass appear magnified and stretched into curved arcs around it.
The ring: When a star sits directly behind the mass (β = 0), its light bends equally around every side and meets at θ = θE, forming an Einstein ring. In our UI model, every active widget calculates its own θE in screen pixels.
What carries over to UI:
- Stronger pull up close: In space, the bend weakens with distance from the mass's centre (
1/θ). On screen, it weakens with distance from the widget's edge, so elements nearest the widget get pushed outward the most. - No blur: Gravity bends light without scattering it, so background content stays crisp instead of frosted.
- No colour splitting: Glass bends blue light more than red, causing rainbow fringes. Because gravity curves spacetime itself, all colours follow the exact same path.
From light to pixels
1. Side on: light bends past the widget on its way to you.
On screen, the widget is the foreground galaxy and the scrolling page is the starfield behind it.
In the lens equation above, the amount light bends is (θE)² / θ. To turn that into a screen-space pull vector, a, around a widget, we make two adjustments:
- Pixels (
E² / d): Measure the distancedand the Einstein radiusEin pixels instead of sky angles. - Shape (
n̂): Measuredfrom the widget's nearest edge, and point the pull outward alongn̂, so gravity wraps evenly around rounded rectangles, pills, and circles.
Two optimizations then keep the pull finite and cheap to draw:
- Soften (
+ c): Add a small constantc, a trick from astrophysics simulations called gravitational softening, sod = 0at the border no longer divides by zero. - Fade (
· f): Taper the pull smoothly to zero atd = 4E, so the browser bends only a small patch around the widget.
Put those together, and you get the pull vector for every pixel around the widget:
E: Einstein radius in pixels (virtual mass grows asE²).d: Distance in pixels to the nearest widget edge (0at the border).c: Softening constant, set per widget, that caps the bend at the edge.f: Inverted cubic smoothstep that fades the pull from 1 at the edge to 0 atd = 4E:f = 1 − 3t² + 2t³, witht = min(d / 4E, 1).n̂: Unit vector pointing straight outward from the nearest edge or corner.
The sampling rule
Split the deflection a into horizontal and vertical screen shifts (a_x, a_y), and you get the rule for every visible pixel:
in: Where the page actually sits in the DOM.out: Where you see it on screen.
Because gravity pushes apparent positions outward by a, the renderer looks backward to draw each pixel. To paint (x, y), it samples the page from (x − a_x, y − a_y) — one step closer to the widget.
Running it in the browser
Real-time canvas or WebGL shaders can't easily read and bend a live, scrolling DOM tree, for security and performance reasons.
The browser-native workaround is CSS backdrop-filter paired with an SVG feDisplacementMap.
feDisplacementMap shifts pixels using the red and green channels of a second image — the displacement map:
- Red channel (
Xaxis): Shifts pixels left or right.128means no movement; above128shifts right, below128shifts left. - Green channel (
Yaxis): Shifts pixels up or down.128means no movement; above128shifts down, below128shifts up. - Blue and alpha: Ignored (
B = 128,A = 255).
Given byte values R and G (0 to 255) and a filter scale factor −s, feDisplacementMap calculates:
Match that to the gravitational deflection rule, and you get the channel values:
Behind the scenes, an offscreen <canvas> draws this map by calculating the distance and outward direction for every pixel around the widget.
Why the pull stops at 4E
Each widget has an invisible field around it, extending 4E past its edges. That field uses backdrop-filter: url(#lens) to bend whatever is behind it — text, images, lists — in real time.
In real space, gravity never hits zero — it just gets weaker with distance.
On screen, rendering that long tail isn't worth the cost, so we smoothly taper the pull to zero at 4E:
- Smaller filter area: A
4Ereach keeps the filter patch tight around the widget. - Cheaper frames: Smaller filter patches mean faster re-renders when content scrolls underneath.
- A calm page: Beyond
4E, pixels stay completely untouched. - No visible seam: Fading the formula smoothly to zero across the
4Ereach prevents any sharp jump at the boundary.
When widgets get heavy
If every control had gravity all the time, the UI would feel unstable. Constant warping tires your eyes, and clicks would miss — because where you see something isn't where the browser thinks it is.
- At rest, most controls are flat: Buttons, sliders, and switches stay at
E = 0. Text stays readable, and what you click is what you get. Floating surfaces are the exception. - Attention adds a little mass: Hover or focus gives an element mild gravity. Pressing down adds more.
- Actions send a ripple: Clicks, toggles, and opening a modal create a short mass pulse — a “gravitational wave” — that fades back to normal.
- Floating bars stay heavy: Navigation bars keep their mass, so content visibly warps as it scrolls underneath.
- Holding and dragging make things heavier: The longer you hold, or the farther you swipe, the stronger the pull.
- Values can set the mass: A continuous control can map its state to gravity — for example, volume scaling
Efrom 4 to 24.
Accessibility note: Respect prefers-reduced-motion. If a user asks for less motion, keep the lens off, or cap it at the lightest mass. The effect should never be the only way to tell what's interactive.
Mass tokens
| Token | E (px) | Application |
|---|---|---|
feather | 6 | Micro-controls under pointer focus |
light | 10 | Primary buttons on hover; pressed micro-targets; active toasts |
medium | 14 | Primary button presses; transition pulses; open menus; floating bars |
heavy | 20 | Pulsing actions; dragged rows; Music's player bar; Chat's input dock |
massive | 28 | Active typing state on input bars |
Working prototypes
Music
A music player. Its bar stays heavy, so track rows bend as they scroll under it. Dragging the seek thumb adds mass, and the volume slider pulls harder the louder it goes.
Chat
A messaging app. Press and hold a message, and it gains mass until its menu opens. The bend around it shows how close the menu is.
Weather
A weather app over rain, clouds, and stars, which bend under its bottom bar as the forecast scrolls. Dragging along the temperature curve bends it around the cursor. Lensing needs detail like this: a flat background gives it nothing to bend.
Technical constraints
- Chromium-only for now: Only Chromium engines (Chrome, Edge, Arc) allow
backdrop-filterto reference an SVG filter. Safari, Firefox, and all iOS browsers ignore it. - 8-bit colour limit: Each channel in
feDisplacementMaponly has 256 steps (0–255). On very wide bends, stretching those 256 steps across a large pixel range can cause subtle stair-stepping along sharp edges.
What this proves — and what it doesn't
It proves you can build a coherent, physics-grounded interaction model out of a single idea — mass — and run it in a real browser with native filters, no WebGL required.
It doesn't prove lensing is better than refraction for everyday UI. It's heavier, it only works in Chromium, and it has to be used sparingly or it gets in the way.
That's the point, though. Liquid Glass asks: “What if UI were glass?” This asks: “What if UI had gravity?” The answer isn't a new default. It's a new material to reach for when weight, attention, and motion are the point.



