Word Magnet, animated React component
A headline whose words behave like fridge magnets: the pointer pushes nearby words away, each one tilts in the direction it was shoved, holds for a beat, then springs home with a wobble. Whole words move, letters never split, and it works with touch as well as a mouse.
- Pro
- Motion Effects
- Hover
- Spring
Play with it
Move the controls and watch it change. Copy code gives you a snippet with only the props you changed.
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| text | string | "Magnetic words react to your cursor and snap back into place" | Text split into magnetic words. |
| radius | number | 130 | Pointer influence radius in px. |
| force | number | 0.45 | Push strength, 0 to 1. |
| damping | number | 28 | Return-spring damping. Lower wobbles longer, higher settles flat. |
| returnDelay | number | 360 | Milliseconds a pushed word holds before springing back. |
| disableOnMobile | boolean | false | Turns the effect off on touch screens and viewports under 768px. |
| overflow | CSSProperties['overflow'] | "visible" | Whether pushed words may spill out of the text box. |
| className | string | — | Classes for the text container. |
| wordClassName | string | — | Classes for every word. |
| style | CSSProperties | — | Inline styles for the container. |
| autoplay | boolean | false | A ghost pointer drifts through the words until a real pointer arrives. |
Add it to your project
- 1
Set up your project once
You need a Next.js project with Tailwind CSS and the
@/import alias. In its root folder, run this once. It createscomponents.jsonand thecn()helper insrc/lib/utils.ts:npx shadcn@latest init -d
Starting from nothing? The Quick Start walks through the whole thing.
- 2
Connect the registry with your API key
Word Magnet is a Pro item, so the CLI has to send your API key. Do this once per project:
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
nxs_and is shown only once. - In your project root, next to
package.json, create a file named.env.localwith this line, using your own key:NEXUS_API_KEY=nxs_your_key_here
- Open
components.jsonand add this entry inside the outermost braces, next to"aliases". Leave{name}and${NEXUS_API_KEY}exactly as written; the CLI fills them in:"registries": { "@nexus-labs": { "url": "https://www.nexus-ui.com/api/registry/{name}", "headers": { "Authorization": "Bearer ${NEXUS_API_KEY}" } } }
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
How Word Magnet works
one tilts in the direction it is shoved, holds for a beat, then springs home on an under-damped spring so it wobbles before it settles. One rAF loop integrates every word and writes straight into motion values.
The source, the install command and the build prompt come with Pro.
About Word Magnet
Word Magnet is a physics-based word layout where individual words repel from cursor proximity using Framer Motion spring animations. Words scatter outward as the mouse approaches and snap back with spring physics when it moves away. Each word is an independent motion element with its own spring configuration. Add it to hero sections or decorative text displays as a memorable interactive moment that rewards visitors who move their cursor into the text.
Good for
- Hero section decorative text
- Interactive brand and tagline displays
- Portfolio and creative agency heroes
- Playful landing page interaction elements