Lens
- Source
- Magic UI ↗
- Author
- Magic UI
- Licence
- MIT
Loading…
A circular magnifier follows the pointer over a photo.
Code
"use client";
import { Lens } from "@/lab/magicui/ui/lens";
export default function LensDemo() {
return (
<div className="relative flex h-full w-full items-center justify-center p-[5%]">
<Lens zoomFactor={2} lensSize={150} isStatic={false} ariaLabel="Zoom Area" className="h-full w-full">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src="https://images.unsplash.com/photo-1736606355698-5efdb410fe93?q=80&w=1400&auto=format&fit=crop&ixlib=rb-4.0.3"
alt="image placeholder"
className="h-full w-full object-cover"
/>
</Lens>
</div>
);
}
Prompt
Build "Lens", a cursor animation. What it does: A circular magnifier follows the pointer over a photo. Write it as a single self-contained React component in TypeScript that fills its parent (w-full h-full), styled with Tailwind CSS, using motion. Technique: the Motion library, pointer tracking. It sits on a light background, in a 16:10 frame. Respect prefers-reduced-motion with a still state, pause work when the element is off screen, and keep it accessible. Original: https://magicui.design/docs/components/lens (Magic UI, MIT).