Skip to content
UISpell
Experiment 01 Material study

Liquid Glass Dock

Drag the slab sideways. It stretches with your hand, the ruler under it slides the wrong way, the ends split into colour, and it settles back into place. Nine lines of physics, no keyframes.

Live study · 01

Drag left or right, then let go. The toggle in the corner swaps the full effect for the fallback that ships with it.

01

What you are feeling

Separate the effect into its parts. Each one is a number you can change.

Stretch
The slab keeps its volume. Pull it right and the trailing edge lags, the body widens, the leading corners tighten into a harder radius. The deformation is a function of velocity — nothing is keyframed.
Refraction
What sits under the glass is not blurred wallpaper but a magnified copy of the page, scaled about your hand. Content near the edge travels further than the slab does, which is why the ruler appears to swim backwards.
Spring
Release and the position integrates a damped spring: k 170, c 16, ζ 0.61. It overshoots about 8% once, then settles. Deformation decays faster than position, so the slab straightens before it stops.
02

The prompt

Written to reproduce the behaviour, not just the look. Paste it into Claude Code, Cursor or v0.

You are a front-end engineer with an eye for materials. Build a single HTML page that demonstrates exactly one idea: a glass dock that deforms under a drag. Every number below exists to make that read as a physical slab, not a decorated rectangle.

[The scene]
- Full-viewport stage, no scroll. Background: a soft three-stop gradient (light: #F6F2EA → #EAE7F4 → #E6F1EC; dark: #08080C → #0C0D16 → #070F11) with three large radial blooms (peach, violet, mint in light; stronger, more saturated in dark). No blur filters on the blooms — radial gradients are already soft, and blurring them costs a full-screen pass twice.
- Structure over the whole scene: 1px vertical rules every 88px plus 1px diagonal rules every 34px at 105° and about 14% ink. Mask both with a soft radial so the centre stays crisp.
- Top-left: a mono kicker, a two-line headline at clamp(30px, 5.2vw, 62px) with -0.045em tracking, and one paragraph at 13px/1.7 in a muted ink.
- Two small spec cards sit above the lower third, plainly bordered, no glass on them.
- Across the dock's travel band, a measuring strip: one hairline, tick marks every 14px (11px tall) with a 70px major tick (24px tall), a row of labels, and large numerals 0–6 at 118px and 11% opacity. This strip is the point: without structure under the glass, refraction is invisible.

[The slab]
- Seven 52px icons, 14px radius, 10px gap, 19px 20px padding, 26px slab radius, sitting in a flex row centred in the lower third.
- Icons are soft-tinted gradient tiles (one hue each, roughly 52% saturation) with a 1px inner top highlight; all glyphs are inline SVG in currentColor.
- Inside the slab, bottom to top: a lens layer that clips a magnified copy of the scene; a tone layer of white 9% → 1% → 5% top to bottom; a dispersion layer with a red gradient at the left end and a cyan gradient at the right, at screen blend, whose opacity is 0 until the slab is deformed; a specular sweep, a 104° white gradient band whose x-offset is driven by velocity; a 1px inner rim that is brightest along the top edge; and an outer shadow of 0 30px 70px -24px at 55% of a violet-black in light, 90% pure black in dark.

[The refraction, exactly]
- Clone the scene subtree once at load, drop its data attributes, mark it aria-hidden, and place it inside the slab at position absolute, left 0, top 0, 100vw × 100vh. Its coordinates are now viewport coordinates.
- Let s = (sx, sy) be the slab's current scale, O the slab's transform-origin (the leading edge, vertically centred), B the slab's untransformed viewport position, P the pointer in viewport coordinates, and x the slab's horizontal translation. Each frame compute
    T = O + ((P - B) - O - (x, 0)) / s - P
  and set on the clone: transform-origin P; transform: translate(T) scale(k/sx, k/sy).
- k = 1.09 + 0.08 × falloff, where falloff eases to 1 while the pointer is on the slab. Applying the inverse of the slab's own scale inside T is what keeps the copy exactly registered with the scene, so the content under the glass is displaced only by the magnification and not by a fudge factor.
- Mask the lens with one static radial gradient: fully opaque to 58%, 82% at 84%, 34% at 96%, transparent at the edge. The ends of the slab therefore fade instead of cutting hard. Never animate a mask per frame.

[The physics]
- Integrate one spring for the horizontal position. While dragging: stiffness 480, damping 38, target = dock start + pointer delta, clamped with a tanh rubber band that allows about 80px of give past the travel limit. On release: stiffness 170, damping 16 (ζ ≈ 0.61, about 8% overshoot) back to zero.
- Deformation e = min(1, |v| / 1100), eased by 0.16 per frame. scaleX = 1 + 0.2e, scaleY = 1 − 0.085e, with the transform-origin on the leading edge so the trailing end stretches and the leading corners tighten.
- Icon magnification: scale 1 + 0.42·exp(−d²/116²), lifting up to 9px, measured from the pointer to each icon's centre.
- Run one requestAnimationFrame loop and stop it entirely once the slab is at rest, the pointer has left and the deformation has decayed. A dock that keeps a rAF loop alive while idle is a battery bug.

[Fallback]
- prefers-reduced-motion, or navigator.hardwareConcurrency ≤ 2, or deviceMemory ≤ 2: start in fallback. No lens, no stretch, position follows the pointer directly with a stiff spring.
- Self-calibrating guard: record the frame rate measured in the first second of interaction on this machine; if a later drag averages under 60% of that baseline for three consecutive one-second samples, switch to fallback. Never use an absolute fps threshold — a throttled tab or a software compositor would be misjudged.
- Expose the same switch as a visible toggle so the fallback can be inspected instead of taken on trust.
- Keep the fallback a real design: tinted slab, rim, icons, still draggable.

[Interaction and access]
- Pointer Events with setPointerCapture, touch-action: none, and a grab/grabbing cursor.
- The dock is role="toolbar"; arrow keys move focus between icons and focus drives the lens, so keyboard users see the material too.
- Every icon has an accessible name. The demo renders no text the user must read to operate it.
- Output one complete HTML5 file. No libraries, no web fonts, no canvas, no WebGL, no SVG filters. Write noindex, nofollow in head and load no analytics.
03

Rules we imposed

  1. 01 One gesture: horizontal drag. No vertical throw, no rotation, no zoom.
  2. 02 One source of colour: the scene under the glass. The slab itself stays neutral.
  3. 03 No keyframes and no transitions on the drag — every frame is derived from position, velocity and the pointer.
  4. 04 Icons never leave the body: magnification is capped so the row stays inside the slab at full stretch.
  5. 05 Nothing moves on its own. Idle is completely still, and the animation loop stops when the slab settles.
  6. 06 The layout is identical with motion off. Reduced motion removes the physics, not the design.
04

Performance fallback

The effect degrades on purpose. A material that only works on a fast laptop is a demo, not a design.

  • Reduced motion: the slab follows the pointer 1:1 with no stretch and no lens; the scene renders once and never again.
  • Low-end devices (two or fewer cores, 2GB or less memory) start in fallback instead of discovering the problem mid-drag.
  • The frame-rate guard is self-calibrating: it records the first second of interaction on that machine and only degrades when a later drag stays under 60% of it for three seconds. An absolute threshold would misfire on throttled tabs and software compositing.
  • The fallback is a designed state, not a broken one: tinted slab, rim, icons, still draggable — the toggle in the corner shows it.

prefers-reduced-motion → fallback · hardwareConcurrency ≤ 2 → fallback · drag fps < 60% of baseline for 3s → fallback

05

What it is not

  • Not a component library. There is no package, no props, no framework port in this release.
  • Not Apple's renderer. It approximates the behaviour that makes glass read as glass, not iOS 26's material internals.
  • Not measured on real low-end Android hardware; the fallback logic is tested by simulation and by the self-calibrating guard, not by a device lab.