Components (13)
Text Hover Effect
NewMotionInteractive typographic SVG reveal effect that traces letter strokes on mount and reveals a vibrant radial gradient mask following cursor movement.
$ pnpm dlx shadcn@latest add @byphongphan/text-hover-effectRequires
@byphongphan in components.jsontext-hover-effect.tsx
Loading preview...
Installation
$ pnpm dlx shadcn@latest add @byphongphan/text-hover-effectRequires
@byphongphan in components.jsonAnatomy
Usage
Features
- SSR-Safe Pure-Math ViewBox: Calculates an accurate initial SVG bounding box mathematically without requiring client DOM access, preventing layout shift and hydration mismatches.
- Isolated Multi-Instance IDs: Automatically scopes SVG gradient, filter, and mask IDs with
useId(), allowing multiple independent instances on the same page without cursor conflict. - Dynamic Gradient Palettes: Pass custom hex color arrays to match brand guidelines, dark cyberpunk themes, or warm sunset palettes.
- Automatic Ambient Sweep: Activate
automatic={true}to continuously sweep the radial spotlight back and forth across the text during idle periods. - Responsive Vector Geometry: Built entirely with scalable vector graphics that seamlessly fit any container width while preserving sharp typographic contours.
Examples
Automatic Ambient Sweep
Autonomously moves the radial gradient mask across the text back and forth when idle, without requiring cursor interactions.
text-hover-effect-automatic.tsx
Cyberpunk Neon Palette
Customize the gradient stops with electric cyan, blue, violet, and hot magenta tones.
text-hover-effect-neon.tsx
Sunset Palette
Warm, energetic color transitions using gold, orange, and purple hues.
text-hover-effect-sunset.tsx
API Reference
TextHoverEffect
Interactive typographic SVG reveal component.
| Prop | Type | Default | Description |
|---|---|---|---|
text | string | — | The text string to render and animate (required). |
duration | number | 0 | Cursor follow interpolation duration in seconds. Set higher for smoother lag effect. |
automatic | boolean | false | When enabled, continuously sweeps the radial gradient across the text when idle. |
strokeDuration | number | 4 | Duration in seconds of the initial outline drawing animation on mount. |
colors | string[] | ["#eab308", "#ef4444", "#3b82f6", "#06b6d4", "#8b5cf6"] | Custom hex or CSS color stops for the hover reveal gradient. |
className | string | undefined | Additional CSS classes for the SVG container. |