Magnetic Focus
A button with a little gravity. Bounded pointer movement, a soft pool of light, and reliable keyboard and touch behavior.
A little source.
A lot of possibility.
Each effect is a React component with a scoped CSS Module. Copy the required files below, preserve their relative imports, and adjust the example to your interface. Keyboard support and motion preferences come with it.
components/forge-factory-01/magnetic-focus.tsxTS/CSScomponents/forge-factory-01/magnetic-focus.module.cssTS/CSScomponents/forge-factory-01/use-reduced-motion.tsTS/CSS03 / CODE & INSTALLATION
Take it from here.
Copy each source file into components/forge-factory-01/. Keep the filenames and their relative imports together. Then use the example below. Use the runtime and file types listed on this effect’s usage notes. The example uses the common @/ import alias; use a relative import if your project has no alias.
import { MagneticFocus } from "@/components/forge-factory-01/magnetic-focus";
export function MyInterface() {
return <MagneticFocus label={"ENTER THE FIELD"} intensity={0.68} paused={false} onClick={() => console.log("Activated")} />;
}The source above powers this preview. Local review build; no published package required.