Scan viewfinder
A camera viewfinder for scanning codes. While searching, four corner brackets breathe over the middle and a line sweeps down; when a code is found they close onto it, then turn green with a tick once read, or shake when it cannot be.
Point at the QR code
When to use
- QR and barcode scanning for payments, tickets, check-in and pairing.
- Document capture where the edges are detected.
When not to use
- Decorating a static image; it should follow a real scanner's state.
- Desktop flows without a camera; offer a code to type.
Installation
pnpm dlx shadcn@latest add @caliper/scan-viewfinder
Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.
API reference
ScanViewfinder
4 props
Also accepts the native props of its root element and a ref.
Keyboard
- No custom key handling; Tab and the native activation keys do the work.
Accessibility
It exposes status semantics, with aria-hidden kept in step with state. Changes that matter are announced through a live region.
Notes for AI
Give your coding assistant this page as Markdown instead of screenshots: the props, keyboard and examples in one file.
/docs/components/scan-viewfinder.mdThe index of every part is at /llms.txt.