All examples

Magnetic dock

Icons grow as the pointer passes, pushing their neighbors aside, and settle when it leaves.

moveInputfollowuseAnimatedCSSmultiply

Preparing the example…

How it works

  1. moveInput writes the pointer's position on the track, from -1 to 1, into one value.
  2. follow makes a second value spring after it, so fast movement stays smooth.
  3. Each icon interpolates its own proximity and multiplies it by a hover value with useAnimatedCSS, because the product of two values is not a calc() expression.
  4. The width changes, so neighbors move in normal layout. Nothing re-renders while the pointer moves.

More examples

Search

Type to search the documentation.