Componentmedia0.58 KB gzipZero dependencies
ZoomImage
Image with hover magnifier lens tracking cursor; framed double border.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add zoom-imageOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { ZoomImage } from "@/components/ui/zoom-image" <ZoomImage src="/placeholder.svg?seed=1" alt="Product image" zoom={2} />Source code
zoom-image.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxzoom-image.tsx70 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export type ZoomImageProps = { src: string; alt?: string; zoom?: number;} & React.HTMLAttributes<HTMLElement>; export function ZoomImage({ src, alt, zoom = 2, ...props }: ZoomImageProps) { const [scale, setScale] = React.useState(1); const [offset, setOffset] = React.useState({ x: 0, y: 0 }); const handleMouseMove = (e: React.MouseEvent) => { const target = e.currentTarget as HTMLElement; const rect = target.getBoundingClientRect();Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { ZoomImage } from "@/components/ui/zoom-image"; <ZoomImage />| Prop | Type | Description |
|---|---|---|
| src | string | Image source URL. |
| alt | string | Optional alt text. |
| zoom | number | Zoom level (e.g., 2 for 2x). |