Docs·Text Repel

Text Repel

A physics-based text animation where each letter reacts to cursor proximity. Letters are pushed away (or attracted) in real-time with spring dynamics, creating an interactive magnetic force-field effect.

Installation

pnpm dlx shadcn@latest add @componentry/text-repel

Usage

API Reference

PropertyTypeDefault
text

The text content to display.

string—
radius

Cursor influence radius in pixels — letters within this distance react.

number120
strength

Maximum displacement in pixels at closest proximity.

number45
mode

Whether letters are pushed away from or pulled toward the cursor.

"repel" | "attract""repel"
stiffness

Spring stiffness — higher values make letters snap back faster.

number180
damping

Spring damping — lower values produce bouncier motion.

number14
mass

Spring mass — higher values make letters feel heavier.

number0.4
className

Additional CSS classes for the container.

string—
letterClassName

CSS classes applied to each individual letter.

string—

View source

Click the icon in the preview panel to browse source for each variant.

Keep in mind

This component is inspired by various open-source projects and patterns. Please verify licenses and implementation details before using in production.

Need a custom component?

I build bespoke UI components & websites tailored to your brand.

DM me on X
Move your cursor here
Move your cursor over the text
import { TextRepel } from "@/components/ui/text-repel"
<TextRepel
  text="Move your cursor here"
  className="text-4xl font-bold"
/>