cnippet/ui
  1. motion
  2. text animations
  3. text cursor proximity

text animations

Text Cursor Proximity

Characters scale, change colour, or transform based on how close the cursor is — any CSS property can be mapped from a resting value to a target value with three falloff curve options for shaping the effect.

Installation

Usage

Anatomy

Good to know

  • containerRef and styles are required. styles maps each CSS property to a from and to value.
  • Letters closer to the cursor move further toward the to values. radius sets the reach and falloff the curve.
  • It follows the mouse, so there's no effect on touch screens.
  • Screen readers read the full text once; the individual letters are hidden from them.
  • When the user has turned on reduced motion, the letters do not react to the cursor and keep their from styles.

Props

Examples

Scale

Characters scale up as the cursor approaches. The radius controls how large the influence zone is.

Opacity Reveal

Two lines start nearly invisible and reveal as the cursor sweeps over them. falloff="gaussian" creates a soft spotlight effect.

Scale and Color

Characters simultaneously grow and shift colour near the cursor. falloff="exponential" sharpens the threshold so the effect only activates very close.