Toggle Sidebar B
AppearanceLight & dark mode D

Magnet

Elements magnetically ease toward the cursor then settle back with spring physics.

Default

Move the pointer near the button and it follows you. Padding and Strength are wired to the controls underneath.

Dark previewReplay previewOpen in new tab

Customize

Padding100px
Strength2

API Reference

Magnet

PropTypeDefaultDescription
paddingnumber100Specifies the distance (in pixels) around the element that activates the magnet pull.
disabledbooleanfalseDisables the magnet effect when set to true.
magnetStrengthnumber2Controls the strength of the pull; higher values reduce movement, lower values increase it.
activeTransitionstring"transform 0.3s ease-out"CSS transition applied to the element when the magnet is active.
inactiveTransitionstring"transform 0.5s ease-in-out"CSS transition applied when the magnet is inactive (mouse out of range).
innerClassNamestring""Optional CSS class name for the moving (inner) element. The outermost wrapper takes the regular class attribute.
SlotDescription
defaultThe content to be displayed inside the magnetized element.

Accessibility

Keyboard shortcuts and ARIA behavior.

  • The effect follows the mouse only. Focus order and the content inside the slot are untouched.
  • Turn it off with the disabled prop for users who prefer reduced motion.