Updated
Pull Toward Cursor
Customize
Strength0.18
Radius110px
Sweep0.9s
Text size48px
Installation
npx shadcn@latest add https://uibrik.com/r/pull-to-cursor.jsonInstall the packages
npm install motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/pull-to-cursor/pull-to-cursor.tsx"use client"; import { cn } from "@/lib/utils"; import { animate, motion, useMotionValue, useSpring, useTransform, type MotionValue } from "motion/react"; import { useEffect, useRef } from "react"; // `play` counts presses of a card's Change button. 0 means the card has not // been pressed yet, so every effect renders its resting state without // animating on page load. export type EffectProps = { play: number }; // Size comes from --text-effect-size (default 1.25rem, i.e. text-xl), so a // preview can enlarge every effect without changing the installed default. const SIZE = "text-[length:var(--text-effect-size,1.25rem)] leading-[1.4]"; const TEXT = `${SIZE} text-zinc-700 font-medium dark:text-zinc-200`; const glyph = (ch: string) => (ch === " " ? " " : ch); // 12 — Letters lean toward the pointer, so spacing tightens where it hovers // and opens again as it moves on. Pressing Change sweeps it across. const AWAY = -9999; export function PullToCursor({
Adds the files to
components/uibrik/pull-to-cursor and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/pull-to-cursor.Usage
import { PullToCursor } from "@/components/uibrik/pull-to-cursor/pull-to-cursor";<PullToCursor play={0} text="Drawn together" strength={0.18} radius={110} sweepDuration={0.9}/>Where to use Pull Toward Cursor
Interactive headlines
Letters leaning toward the cursor like a magnet make a title respond to the visitor.
Pairs with Hover Weight
Agency sites
Magnetic type is a small interaction that signals attention to detail.
Fun 404 pages
Something that follows the pointer softens a dead end.
Props
PullToCursor- text
- Type string
- "Drawn together"
- The copy to animate.
- strength
- Type number
- 0.18
- How far letters lean toward the pointer.
- radius
- Type number
- 110
- Reach of the pull.
- sweepDuration
- Type number
- 0.9
- Replay sweep across the line.
- playrequired
- Type number
- –
- Each change plays the effect again; 0 shows its resting state.