Introducing Motion-Primitives Pro - Advanced components and templates to help you build a website that stands out.

Magnetic

A magnetic effect for elements that allows them to be attracted to the mouse cursor.

Examples

Magnetic Basic

Magnetic Nested

You can nest the Magnetic component to create a more complex effect. Here we use actionArea='global' to make the magnetic effect apply to the global area. We also use custom range to make the magnetic effect apply to a larger area.

Installation

npx shadcn add "https://motion-primitives.com/c/magnetic.json"

Component API

Magnetic

PropTypeDefaultDescription
childrenReact.ReactNodeThe child elements to be displayed within the magnetic effect.
intensitynumber0.6The strength of the magnetic effect, scaling the distance effect.
rangenumber100The effective range in pixels within which the magnetic effect is applied.
actionArea'self' | 'parent' | 'global''self'Determines whether the magnetic effect is triggered by the component, its parent, or globally.
springOptionsSpringOptionsSPRING_CONFIGThe spring options to be used for the magnetic effect.