Liquid Proximity Typography

Letters scale and lift on springs as the pointer approaches, and a click sends a shock along the word.


Liquid Proximity Typography


Liquid proximity type is a word whose letters have weight in the physical sense. A letter near the pointer grows and rises. A letter the pointer has left eases home. A click sends a narrow shock along the baseline, so the word reacts as a line of masses instead of a single hover state.

The letters are real text in an h1. The script only writes transform and a color mix. The accessible name stays on the heading. This is a different effect from the wavy text animation, which is a timed wave, and from the typewriter, which reveals characters. Here the word is complete the whole time. The pointer changes its posture.

Per-letter springs

Each letter keeps scale, vertical offset, and a velocity for both. The target scale is 1 plus a squared falloff out to 240 pixels, times 0.62. The target lift is the same falloff times -22 pixels, plus a 4 pixel idle sine so the word breathes when nobody is there.

const influence = Math.max(0, 1 - dist / 240);
const targetScale = 1 + influence * influence * 0.62;
const targetY = -influence * 22;
[letter.s, letter.vs] = spring(letter.s, letter.vs, targetScale, 90, 16, dt);
[letter.y, letter.vy] = spring(letter.y, letter.vy, targetY, 80, 15, dt);

Stiffness near 90 with damping near 16 is the smooth setting. Higher stiffness tracks the pointer like a magnet and feels nervous. Lower stiffness feels late. Measure letter centers with getBoundingClientRect each frame. The transform does not change layout width enough to make the centers lie, because scale does not affect layout. The centers stay honest.

The shock

A click records an x and a time. Each frame, a Gaussian ring travels outward at about 780 pixels a second. Letters whose centers sit on that ring get an extra scale and an extra lift, faded by the shock’s age. The ring is horizontal because a word is a line. A radial ring would lift letters above and below a point that is not on the page.

Color follows scale. At rest the letter is #1a1612. As scale climbs, it mixes toward clay #c45c26. The color is a consequence of the spring, not a second animation, so it cannot get ahead of the motion.

When the pointer leaves

After about 1.2 seconds without a move, a horizontal Lissajous stands in for the pointer and the word keeps breathing. That is what a preview and a first visit should see. The moment a real pointer moves, the stand-in is dropped.

Reduced motion sets scale to 1 and offset to 0 and leaves the heading as ordinary type. Do not hide the word until the script runs. The letters are in the HTML before the loop starts.

Questions about proximity type

How do I make text react to the cursor?

Split the word into letter spans. Each frame, measure the distance from the pointer to the letter center, turn that into a falloff, and spring the letter’s scale and translate toward the falloff. Keep the full word as the heading’s accessible name.

Why do the letters jitter?

You are setting the transform from the raw pointer with no velocity, or you are reading layout from a box that your own scale is changing. Springs remove the jitter. scale() does not change layout, so reading the border box is stable.

Can this use a variable font axis instead of scale?

Yes, if you load a variable font and spring font-variation-settings weight. That is heavier per frame and the axis range is the font’s, not yours. Scale is available on every face and stays on the compositor. Use a weight axis when the thickening itself is the point. Use scale when you want the letter to feel closer.