Nudge
Text
Type
Colour
Ground
Motion
About this effect
Nudge gives a heading personal space. As the cursor comes near, the closest letters are pushed away from it, as far as the push allows, take on the accent colour and tip a little in the direction they are moving; when it leaves they spring back into line with a wobble. With no pointer, a ghost cursor drifts across now and then so the heading still moves.
A small script keeps a spring for every letter and writes its offset, tilt and closeness as custom properties each frame; the CSS turns them into a transform and a colour mix. It pauses when the heading is off screen. On touch screens a finger does the nudging.
Reach sets how far the cursor's influence spreads across the line, and push how far the letters move. It works best on a short line with real space round it.
- Formats
- React, HTML
- No dependencies
- Built with
- CSS and a little JS
- Default font Space Grotesk
- Plays
- Loop, Hover
- Reduced motion
- Respected
- Shows the finished frame
Accessibility. The heading is named by its full text; the letter spans are hidden from screen readers. Under reduced motion the letters stay in line and ignore the pointer.
Also known as text repel cursor, magnetic text, interactive text, cursor push letters, spring text animation, mouse follow text.
Use it in anything you build, client work included, no credit needed. Don’t republish or resell the effect itself.