
Click to Scan

Repeating Scan

Button Triggered
Installation
Usage
import { ImageScanner } from "@/components/ui/image-scanner";
export default function MyComponent() {
return (
<div className="w-full max-w-md mx-auto">
<h1 className="text-2xl font-bold mb-8 text-center">Horizontal Scan</h1>
<ImageScanner
image="/path-to-image.png"
scanDirection="horizontal"
scanColor="emerald"
scanType="both"
autoScan={true}
repeating={true}
/>
</div>
);
}
// With scan completion callback
export function ScanWithCallback() {
const handleScanComplete = () => {
console.log("Scan completed!");
// Perform actions after scan completes
};
return (
<div className="w-full max-w-md mx-auto">
<h1 className="text-2xl font-bold mb-8 text-center">
Scan with callback
</h1>
<ImageScanner
image="/path-to-image.png"
scanDirection="vertical"
scanColor="blue"
scanType="line"
onScanComplete={handleScanComplete}
/>
</div>
);
}
Props
Image Scanner
Prop | Type | Default | Description |
---|---|---|---|
image | string | undefined | URL or path to the image to be scanned. |
alt | string | "Scanning image" | Alternative text for the image. |
scanDirection | "horizontal" | "vertical" | "horizontal" | Direction of the scanning effect. |
scanSpeed | number | 2 | Speed of the scanning animation in seconds. |
scanColor | "emerald" | "blue" | "purple" | "amber" | "red" | "emerald" | Color of the scanning effect. |
scanType | "line" | "corners" | "both" | "both" | Type of scanning visual effect to display. |
className | string | undefined | Additional CSS classes to apply to the container. |
onScanComplete | () => void | undefined | Callback function triggered when scanning is complete. |
autoScan | boolean | false | Automatically start scanning when component mounts. |
scanDelay | number | 0 | Delay in seconds before starting the auto scan. |
scanAtScroll | boolean | false | Trigger scan when component is scrolled into view. |
repeating | boolean | false | Enable repeated scanning in a loop. |
triggerScan | boolean | false | Externally trigger the scanning effect. |