Skip to content
Sign upPro
ShellCamera captureMenu

Camera capture (Pro)

ProIncluded in $99

Point the camera at something and ask about it: the subject is outlined, the shot freezes into a crop, and the question goes with the picture.

ProTake the photo, nudge the crop, ask. The cropped picture and the question land in the chat.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/camera-capture

Needs chatcn Pro

This command works with a Pro license, along with every Pro component.

Or start free: sign up and get three Pro components on us, with a new one every month.

Usage

tsx
import { CameraCapture } from "@/components/ui/chatcn/pro/camera-capture"

<CameraCapture
  stream={cameraStream}                          // from getUserMedia; or still={{ src, alt }} for demos
  subject={{ x: 0.1, y: 0.25, w: 0.78, h: 0.49 }} // from your detector, in fractions of the frame
  suggestions={["How do I replace the ribbon on this?", "What model is this?"]}
  onAsk={({ image, prompt }) => sendToChat(image, prompt)}
  onClose={closeCamera}
/>

Laid out like the phone's own camera: black bands with close and flash above, the viewfinder in the middle, the shutter below. When you pass a subject (from your own detector), it is outlined in the viewfinder. The shutter flashes and freezes exactly what the viewfinder showed; a crop box starts on the subject, or in the middle, with the rest dimmed. Drag the box or its corners, or focus it and use the arrow keys (Shift resizes). A suggested question sends at once, or type one. onAsk gets the cropped picture as a JPEG data URL at the camera's full resolution, the crop and the prompt. Retake goes back to the live view. With no stream, still stands in for the camera.

Examples

States

ProAt real phone width with no subject found: the crop starts in the middle.

Props

PropTypeNotes
streamMediaStream | nullA live camera
still{ src, alt }A photo standing in for the camera
subject{ x, y, w, h }In fractions of the frame; outlined and the crop starts there
suggestionsstring[]Question chips after the shot
onAsk(result) => void{ image, crop, prompt }
onClose() => voidThe close button
labelsPartial<CameraCaptureLabels>Every string, for translation

Keyboard

KeyAction
Arrow keys on the cropMove it
Shift with arrow keysResize it
Enter in the fieldAsk

Accessibility

  • Every control is a named button; flash reports whether it is on.
  • The crop is a focusable slider that says its size, with keyboard moves and resizing.
  • The outlined subject is announced as Subject found.

Motion

A white flash fades over 380 ms on the shutter. Under reduced motion there is no flash.