115 Components

Text Hover Lens

Text

Interactive text component where hovering opens a circular lens under the cursor with spring physics, revealing a contrasting color layer with optional magnification.

NewHoverLensSpringReveal
/r/text-hover-lens.json

HOVER TO REVEAL

Move cursor across typography • Snappy spring lens follows pointer

Installation

Install directly into your project using the shadcn CLI or copy the source code manually.

Requires:framer-motionclsxtailwind-merge
$npx shadcn@latest add "https://boseui.site/r/text-hover-lens.json"

Props

TypeScript props supported by <TextHoverLens />.

9 props
PropTypeDefaultDescription
textrequiredstring—The text string to display and reveal through the lens.
lensColorstring"#0d9488"Background color of the circular lens disc. Accepts any valid CSS color.
lensTextColorstring"#ffffff"Color of the revealed text inside the lens disc. Must provide AA contrast against lensColor.
textColorstring"currentColor"Color of the base text outside the lens.
lensSizenumber120Diameter of the circular lens in pixels when fully open.
magnifynumber1Scale multiplier for text inside the lens. 1 = no zoom, 1.2 = slight zoom.
stiffnessnumber380Hooke's Law spring stiffness coefficient matching the Snappy preset.
dampingnumber24Spring damping coefficient controlling oscillation decay matching the Snappy preset.
classNamestringundefinedAdditional Tailwind or CSS classes applied to the outer wrapper.

Key Features

  • Dual-layer text architecture with zero layout shift and identical font metrics.
  • Dynamic clip-path circle driven by Framer Motion motion values without React re-renders during mouse movement.
  • Snappy spring physics preset (stiffness 380, damping 24) for natural cursor follow and soft open/close overshoot.
  • Customizable magnification scale, lens diameter, and full CSS color support (hex, rgb, hsl, CSS variables).
  • Touch device support with touch-down reveal and non-blocking page scroll.
  • Respects system prefers-reduced-motion by bypassing spring physics for instant alignment.

Keyboard & Accessibility

  • Aria-hidden on the decorative lens layer ensures screen readers announce the text exactly once.
  • Base layer text remains fully selectable with pointer-events: none on the overlay.
  • Respects prefers-reduced-motion settings out of the box without jarring layout shifts.