Introducing Magic UI Pro - 50+ blocks and templates to build beautiful landing pages in minutes.

19.0k
173

Lens

PreviousNext

A interactive component that enables zooming into images, videos and other elements.

Installation

pnpm dlx shadcn@latest add @magicui/lens

Examples

Static Lens

Lens with a Default Position

Usage

import { Lens } from "@/components/magicui/lens";
<Lens>
  <img src="/images/lens-demo.jpg" alt="Lens Demo" />
</Lens>

Props

PropertyTypeDefaultDescription
childrenReact.ReactNode-The content that will be magnified by the lens
zoomFactornumber1.3The magnification factor of the lens
lensSizenumber170The size of the lens in pixels (works as a diameter)
positionPosition-The current position of the lens
defaultPositionPosition-The initial position of the lens
isStaticbooleanfalseDetermines if the lens will remain in a fixed position
durationnumber0.1Duration of the animation when the lens moves (in seconds)
lensColorstring-The color of the lens (CSS color value)
ariaLabelstring-Accessibility label for the lens component