Cursor & pointer

Magnetic

Elements that get pulled toward the pointer as it approaches, then snap back on a spring.

Paste it into ChatGPT, Claude, Cursor or v0.
strength0.40
radius90
scale1.06
inner parallax0.30
spring

Usage

import { Magnetic, useMagnetic } from '@vizzele/react';

<Magnetic strength={0.4} radius={90} inner=".label">
  <button className="vz-button" data-variant="holo">
    <span className="label">Hover me</span>
  </button>
</Magnetic>

// or as a hook
const ref = useMagnetic<HTMLButtonElement>({ strength: 0.4 });
<button ref={ref}>Magnetic</button>

Props

PropTypeDefaultDescription
strengthnumber0.35How much it follows the pointer (0–1).
radiusnumber80Extra px around the element where the pull starts.
scalenumber1.04Scale while attracted.
innerstring | HTMLElement—A child that moves further (layered parallax).
innerStrengthnumber0.2Extra movement of the inner element.
pressbooleantrueSquish on press — the touch alternative to hover.
springSpringConfig | SpringPreset'liquid'Spring used to follow and return.

Accessibility

  • Purely visual: the element keeps its role, focus and click target.
  • On touch devices there is no hover, so it gives press feedback (squish) instead.
  • With reduced motion the element stays in place.