Micro-interactions

Refract

A frosted-glass slab you drag across a live scene, refracting it through a real shader optic — a rounded-rect height field whose gradient bends three separately-sampled color channels, with a Fresnel-bright rim, a travelling specular streak, and a frost that is a genuine multi-tap blur of what sits beneath the pane. Where Lens bends its DOM children through an SVG displacement map and magnifies, Refract is a flat pane over a scene texture: true angle-of-incidence refraction, dispersion and glare — and the scene it bends is drawn in the same shader, because no browser lets WebGL read the rendered page. Throw it and it glides on momentum, rubber-banding off the container walls.

Install

bun add ogl

Then copy 2 files into your project:

  • components/registry/refract/refract.tsx
  • hooks/use-animation-loop.ts

Props

PropTypeDefaultDescription
iornumber0.18Refraction strength at the bevel. The flat middle passes almost straight through, exactly like a real pane.
dispersionnumber0.35R/G/B sample spread — the chromatic fringe that gathers on the bevel.
frostnumber6Blur radius under the glass.
edgeWidthnumber0.18Fraction of the slab that is bevel — all of the bending and most of the glare lives there.
glarenumber0.5Fresnel rim and travelling specular strength.
slabWidthnumber46Slab width as a fraction of the container.
scene"blobs" | "stripes" | "checker""blobs"The procedural backdrop being refracted. High-frequency scenes show the dispersion hardest.
tintstring (hex)"#e9e6ff"Glass body tint.

What It Demonstrates

Drag
Moving an element by grabbing it, often with momentum when released.
Momentum
Motion that carries velocity, especially after a drag or interruption.
Blur
A blur filter used to soften an element or mask tiny imperfections.
Loop
An animation that repeats, a set number of times or infinitely.

Related Components

Appears In