Magnetic
A spring-follow wrapper — the surface leans toward the cursor and settles back.
Live — this one is real
Move your cursor close — the surface answers
Usage
import { Button, Magnetic } from "mizu-ui";
export function PullTab() {
return (
<Magnetic strength={0.4}>
<Button>Pull</Button>
</Magnetic>
);
}
Source & setup
Add this component to your project with the shadcn CLI. The command copies its source into your configured UI directory, with base.css, Mizu’s tokens, and the stylesheets that hold its rules. Each rule lives in one stylesheet, so components you add together never repeat CSS. In a project without a components.json, run npx shadcn@latest init 0xuser64bit/mizu/preset first: plain init installs shadcn’s theme into your global CSS. Then load the fonts.
npx shadcn@latest add 0xuser64bit/mizu/magnetic 0xuser64bit/mizu/buttonThe example also uses Button, so the command adds it too.
Every component imports from its own path, its name in kebab case. To paste the example, replace its mizu-ui import with:
import { Magnetic } from "@/components/ui/mizu/magnetic";
import { Button } from "@/components/ui/mizu/button";For npm imports, import mizu-ui/styles.css once. Fonts are optional via mizu-ui/fonts.css. Override --mizu-* tokens or use className for local styling. Requires React and Motion. A Client Component: its source starts with “use client”.
Inspect motion/Magnetic.tsx
Source is included in the npm package under src/motion/Magnetic.tsx.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| strength | number | 0.32 | Fraction of the distance to the cursor that the element travels. |
Accessibility
Purely presentational — the wrapped control keeps its own keyboard and screen-reader behavior.
Motion
Spring (stiffness 160, damping 14) on both axes. Travel is disabled by the reduced-motion hook.