Skip to content
caliper ui pro docs

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.

Pro

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

terminal
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.

PropTypeDefaultDescription
children *ReactNode—What the camera sees: a video, an image or a live preview.
state *ScanState—
boxScanBox[0.3, 0.3, 0.4, 0.4]Where the code is once found; the brackets close onto it.
hintstring—Says what to point at, e.g. "Point at the QR code on the receipt".

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.md

The index of every part is at /llms.txt.

More in Media