Kinetic UI
Back to Introduction
Mouse Interactions

Magnifying Glass

An x-ray lens that reveals a secret layout underneath your cursor.

Quick Actions
CLI Installation
npx kinetic-ui-cli@latest add magnifying-glass

The MagnifyingGlass component creates a stunning "x-ray" or "flashlight" effect by rendering two completely different layouts on top of each other.

It uses framer-motion to track the user's cursor with spring physics, and applies a dynamic CSS mask-image with a radial gradient to the top layer. The result is a smooth, performant lens that reveals the secret lensContent exactly where the user hovers!

Live Preview

Magnifying Glass

Beautiful UI

This is what your users see. Clean, minimal, and highly polished interfaces. Hover to reveal the underlying structure.

<Code />

function Button() { return ( <motion.button className="bg-indigo-500" whileHover={{ scale: 1.05 }} /> ) }

Primary
Secondary

Installation

npx kinetic-ui-cli@latest add magnifying-glass

[!TIP] Performance: We use native CSS custom properties (--lens-x, --lens-y) inside a Framer Motion onUpdate callback to update the mask position. This bypasses the React render cycle completely, guaranteeing 60fps tracking even if the underlying layouts are extremely complex.

Usage Guide

1. Import the Component

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

import { MagnifyingGlass } from "@/components/creative/magnifying-glass";

2. Implementation Example

Render the component and customize its behavior by passing props:

import { MagnifyingGlass } from "@/components/creative/magnifying-glass";

export default function Example() {
  return (
    <div className="w-full flex items-center justify-center p-8">
      <MagnifyingGlass
        mainContent{/* value */}
        lensContent{/* value */}
        lensSize{10}
      />
    </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.