Join our Discord Community

React Text Reveal

Interactive text reveal with cursor-based animations. Perfect for React applications requiring dynamic text reveals with TypeScript support.

Powered by

Trying to implement text animations?

Join our Discord community for help from other developers.


Most text reveal effects just use simple opacity transitions or basic slide animations that feel generic. This component creates an interactive reveal where moving your cursor horizontally unveils hidden text using clip-path animations. The effect feels like wiping away a layer to discover what's underneath, creating engaging, discoverable content.

Cursor-controlled text reveal with clip-path animations

Hidden text that reveals as you move your cursor across it:

Loading component...

Built with TypeScript and Motion for React applications, using clip-path animations and real-time cursor tracking. The reveal follows your mouse position precisely, creating that satisfying "wiping away" interaction that encourages exploration.

Installation

npx shadcn@latest add https://www.shadcn.io/registry/text-reveal.json
npx shadcn@latest add https://www.shadcn.io/registry/text-reveal.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/text-reveal.json
bunx shadcn@latest add https://www.shadcn.io/registry/text-reveal.json

Usage

import { TextReveal } from "@/components/text/text-reveal";

<TextReveal
  text="You know the business"
  revealText="I know the chemistry"
  className="h-20"
/>;

Why most text reveals suck

Most developers use basic CSS transitions—fade in, slide up, or simple opacity changes. The result feels predictable and passive. Users just watch text appear without any control or interaction. There's no exploration, no discovery, just another automatic animation.

This React component uses cursor-based clip-path animations that respond to mouse movement in real-time. Moving left to right gradually reveals the hidden text through precise clip-path calculations. The revealed text appears with smooth transitions while the base text remains visible underneath, creating depth and context.

The key insight: interactive reveals create engagement. When users control the reveal speed and direction with their cursor, they feel agency over the content discovery. The clip-path approach ensures smooth, pixel-perfect reveals that feel natural and responsive.

Features

  • Real-time cursor tracking with precise clip-path reveal animations for React applications
  • Smooth transitions between hidden and revealed states using Motion animations
  • Touch support for mobile devices with equivalent swipe-based reveals
  • Configurable text content with separate base and reveal text options
  • Complete TypeScript support with proper event handling and ref management
  • Performance optimized with efficient DOM measurements and clip-path calculations
  • Free open source component compatible with Next.js and shadcn/ui design systems

API Reference

TextReveal

Interactive text component with cursor-controlled reveal animations.

PropTypeDefaultDescription
textstringrequiredBase text content (partially visible)
revealTextstringrequiredHidden text revealed on interaction
classNamestring-Additional CSS classes for container

Optimal Usage Patterns

Design reveals that enhance content discovery:

Content TypeBase TextReveal TextEffect
Questions"What is the secret?""Hard work and patience"Discovery
Before/After"We build websites""We create experiences"Transformation
Mysteries"The hidden truth...""Innovation never stops"Revelation
Contrast"Everyone thinks...""But reality shows..."Surprise

Text Length Guidelines

Balance readability with reveal effect:

Text LengthUser ExperienceBest Practice
Short (1-3 words)Quick, clear revealPerfect for key phrases
Medium (4-8 words)Balanced interactionIdeal for most content
Long (9+ words)Extended interactionConsider breaking up

Common gotchas

Reveal doesn't follow cursor precisely: The component calculates position based on container bounds in React applications. Ensure the container has proper dimensions and positioning. Padding or margins might affect cursor tracking accuracy in TypeScript projects.

Text jumps during reveal: Both text layers should have identical styling for smooth transitions in JavaScript applications. Mismatched font sizes, weights, or line heights cause visual jumps during the clip-path animation in Next.js projects.

Mobile touch events don't work: The component includes touch handlers for mobile devices in React applications. However, continuous touch tracking differs from mouse movement. Consider longer touch interactions or alternative mobile reveals in TypeScript projects.

Performance issues on complex layouts: Clip-path animations are GPU-accelerated but frequent cursor updates can impact performance in JavaScript applications. The component uses efficient event handling and requestAnimationFrame for smooth animations in React projects.

Accessibility concerns for screen readers: Screen readers may not interpret the reveal interaction intuitively in TypeScript applications. Consider providing alternative text access or keyboard navigation options for inclusive experiences in Next.js projects.

Integration with other components

Perfect for hero sections in Card layouts or interactive headers in Sheet overlays within React applications. Works excellently with Button components for action-reveal combinations in Next.js projects.

For storytelling interfaces, combine with Progress indicators or Tabs for sequential reveals. This TypeScript component pairs well with Badge for category reveals and Avatar for profile information discovery, all with seamless shadcn/ui integration.

Questions developers actually ask