BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/atlas-ui/magnetic-hover

Magnetic Hover

atlas-ui/magnetic-hover
FreeComponent

A smooth magnetic hover interaction that subtly pulls elements toward the with using spring based motion animations.

Live preview

live · rendered by the registry
Rendered by atlas-ui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://atlasui.dev/r/magnetic-hover.json

Source

registry/react/atlasui/magnetic-hover.tsxatlasui.dev/r/magnetic-hover.json
1"use client";
2
3import { useRef, useState } from "react";
4
5import { motion } from "motion/react";
6
7interface MagneticHoverProps {
8 children: React.ReactNode;
9 strength?: number;
10}
11
12export const MagneticHover = ({
13 children,
14 strength = 1,
15}: MagneticHoverProps) => {
16 const ref = useRef<HTMLDivElement>(null);
17
18 const [position, setPosition] = useState({ x: 0, y: 0 });
19
20 const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
21 if (!ref.current) return;
22
23 const { left, top, width, height } = ref.current.getBoundingClientRect();
24 const x = (e.clientX - (left + width / 2)) * strength;
25 const y = (e.clientY - (top + height / 2)) * strength;
26 setPosition({ x, y });
27 };
28
29 const handleMouseLeave = (e: React.MouseEvent<HTMLDivElement>) => {
30 setPosition({ x: 0, y: 0 });
31 };
32
33 const { x, y } = position;
34
35 return (
36 <motion.div
37 ref={ref}
38 onMouseMove={handleMouseMove}
39 onMouseLeave={handleMouseLeave}
40 animate={{ x, y }}
41 transition={{ type: "spring", stiffness: 150, damping: 15, mass: 0.2 }}
42 >
43 {children}
44 </motion.div>
45 );
46};

What it pulls in

npm packages

  • motion

Files it writes

  • registry/react/atlasui/magnetic-hover.tsx

Facts

Registry
atlas-ui
Type
registry:component
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-01
Last confirmed
yesterday

Go to the source

Docs on atlas-ui atlasui.dev SnehdeepDupare/atlas-ui on GitHub Raw registry item This item as JSON

More from atlas-ui

All 99 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Animated Mobile Navbaranimated-mobile-navbaratlas-uiComponentsFree2 deps
Blend Mouse Trailerblend-mouse-traileratlas-uiComponentsFree1 dep
Blob Mouse Trailerblob-mouse-traileratlas-uiComponentsFree1 dep
Box Revealbox-revealatlas-uiComponentsFree1 dep
Cascade Textcascade-textatlas-uiComponentsFree1 dep
Dot And Circle Mouse Trailerdot-and-circle-mouse-traileratlas-uiComponentsFree1 dep
Fancy Theme Togglefancy-theme-toggleatlas-uiComponentsFree1 dep
Hacker Texthacker-textatlas-uiComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex