Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

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.

Push these words around and watch them wobble back into place

Props

PropTypeDefaultWhat it does
text"Magnetic words react to your cursor and snap back into place"Text split into magnetic words.
radius130Pointer influence radius in px.
force0.45Push strength, 0 to 1.
damping28Return-spring damping. Lower wobbles longer, higher settles flat.
returnDelay360Milliseconds a pushed word holds before springing back.
disableOnMobilefalseTurns the effect off on touch screens and viewports under 768px.
overflow"visible"Whether pushed words may spill out of the text box.
className—Classes for the text container.
wordClassName—Classes for every word.
style—Inline styles for the container.
autoplayfalseA ghost pointer drifts through the words until a real pointer arrives.

Add it to your project

  1. 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 creates components.json and the cn() helper in src/lib/utils.ts:

    npx shadcn@latest init -d

    Starting from nothing? The Quick Start walks through the whole thing.

  2. 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:

    1. Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with nxs_ and is shown only once.
    2. In your project root, next to package.json, create a file named .env.local with this line, using your own key:
      NEXUS_API_KEY=nxs_your_key_here
    3. Open components.json and 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}"
          }
        }
      }

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