Kinetic UI
Back to Introduction
Layout

Magnetic Gallery

A grid of images that slightly rotate in 3D space to track the global mouse position.

Quick Actions
CLI Installation
npx kinetic-ui-cli@latest add magnetic-gallery

The MagneticGallery component creates a stunning layout where every image tracks the global mouse vector. By calculating the distance from the mouse to the center of each image, we map that proximity to Framer Motion's rotateX and rotateY transforms, creating a localized magnetic "look at" effect.

Live Preview

Magnetic Gallery

Move Your Mouse

Notice how the images tilt to track your cursor globally.

Abstract landscape
Architecture detail
Minimalist interior

Installation

npx kinetic-ui-cli@latest add magnetic-gallery

Usage Guide

1. Import the Component

Import the component into your React or Next.js page:

import { MagneticGallery } from "@/components/creative/magnetic-gallery";

2. Implementation Example

Render the component and customize its behavior by passing props:

import { MagneticGallery } from "@/components/creative/magnetic-gallery";

export default function Example() {
  return (
    <div className="w-full flex items-center justify-center p-8">
      <MagneticGallery
        images="example"
      />
    </div>
  );
}
Performance Notes
  • Uses CSS hardware acceleration via GPU transform-binds.
  • Damped interpolation minimizes paint-redraw flashes.
  • Tree-shakable import: only compiles elements requested.
Accessibility Notes
  • Full keyboard focus-ring navigation support (`Tab`/`Shift+Tab`).
  • ARIA roles mapped correctly for assistive screen readers.
  • Respects `prefers-reduced-motion` system toggles.