Liquid glass toolbar over scrolling DOM

I wanted to know if a floating HTML navigation pill can refract a live scrolling article behind it using Snell's-law lensing and chromatic dispersion in WebGL, while both the toolbar and the page underneath stay clickable and selectable. Scroll the article, drag the pill across the high-contrast cards, and try the buttons on both layers.

Optical notes · live scrollable DOM

Refracting live markup behind a floating bar

Everything inside this scroll container is ordinary HTML drawn into a single WebGL 2 canvas with texElementSubImage2D(). Try selecting this sentence with your cursor, or scroll the high-contrast bands below under the curved edge of the floating pill.

Dark and light contrast cards

Tap any card to mark it while the glass pill floats nearby. The curved bevel bends vertical borders and splits red, green and blue across the high-contrast seams.

1.52
Crown glass IOR
Bends rays inward along the rounded bevel normal.
9-tap
Frosted micro-blur
Softens small text through the thick centre of the pill.
R/G/B
Chromatic dispersion
Offsets three refractive indices near the curved rim.
F(θ)
Fresnel rim glint
Grazing edges catch light as the pointer moves across.
2×
Two DOM layers
Article texture underneath, toolbar texture composited on top.
Hit
Synced geometry
Both the scrolling article and dragged pill receive clicks.

Interactive checkboxes behind the glass

2 of 3 checked

Live form inside the scrolling layer

Type an address and press Subscribe to test focus and form submission underneath the floating pill.

End of specimen

Extra space below the form lets you scroll the dark form card and checkboxes right behind a bottom-docked toolbar. Try switching presets or dragging the pill over the heading above.

 

Show the code two-pass ElementGL liquid glass shader, scrolling upload and synced hit boxes
  1. Two drawable children in one canvas. The scrollable article fills the stage; the floating toolbar sits at the top-left in layout and moves via updateElementGeometry().
  2. The fragment shader. Pass 0 draws the scrolling article. Pass 1 computes a rounded-rectangle SDF normal map, refracts the article texture with Snell's law and chromatic dispersion, applies a 9-tap frost blur and Fresnel specular rim, then composites the live toolbar on top.
  3. On paint. Upload both elements into one ElementGL context, bind the article texture to unit 1 for the glass pass, and sync hit boxes with updateElementGeometry().
  4. Dragging and presets. Move the pill by pointer or touch, keep clicks on toolbar buttons working, and toggle dataset.hitTick when the hit box moves.

How it works

This experiment takes inspiration from Apple's Liquid Glass material design (WWDC 2025) and community WebGL and WebGPU refractive glass UI demos. CSS backdrop-filter: blur() can frost pixels behind a floating bar, but it can't bend them around a curved bevel or split red, green and blue like a physical lens. HTML-in-canvas gives a fragment shader the live rendered pixels of the DOM behind the bar as a GPU texture, so the shader can run Snell's law on every frame while the markup stays interactive.

Both #lg-page (the scrollable article) and #lg-dock (the floating navigation pill) live inside one <canvas content="drawable" layoutsubtree> managed by ElementGL from /lib/element-gl.js. Inside the paint handler, each element is uploaded with gl.texElementSubImage2D() when it changes or when the article scrolls. Pass 0 draws the article across the full canvas. Pass 1 draws a quad at the pill's current rectangle, binds the article texture to TEXTURE1 and the pill's own DOM texture to TEXTURE0, evaluates a rounded-rectangle signed distance field for the curved glass bevel, refracts three slightly different indices of refraction for red, green and blue, adds a 9-tap frosted micro-blur and pointer-lit Fresnel highlight, and composites the crisp toolbar pixels over the glass body.

Because the pill is drawn at its dragged coordinates rather than at its CSS layout origin, the paint handler calls canvas.updateElementGeometry() for both children (scaled by geometryUnit() from /lib/surface.js for high-DPI screens) and toggles dataset.hitTick whenever the pill moves to clear Chromium's hit-test cache. When WebGL texElementSubImage2D() isn't available, the page falls back to a 2D frosted draw with drawElementImage() or unwraps the markup as plain HTML with backdrop-filter: blur().

Live checks

These run on their own small fixtures in the corner of the window and leave the demo above untouched.

Findings