Skip to content
Sign upPro
ComposerRegion captureMenu

Region capture (Pro)

ProIncluded in $99

Pick part of a screen and attach it: drag a selection with its size in real pixels, capture it at full resolution, and watch it land in the message.

ProAn analyst drags over the spend chart, captures it, and the crop flies into the message beside the question.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/region-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 { RegionCapture } from "@/components/ui/chatcn/pro/region-capture"

<RegionCapture
  src={frameUrl}
  alt="The billing dashboard"
  flyTo={() => attachmentsRef.current}
  onCapture={({ dataUrl, rect }) => attach(dataUrl, rect)}
/>

Give it a frame of the screen (for example one frame from getDisplayMedia, drawn to a canvas) and it handles the rest. The frame dims except for the selection, which has a crisp edge, eight handles (two on a small selection, so they never clump) and its size in the frame's own pixels. Drag to draw, drag inside to move, drag a handle to resize. Capture crops the region from the full resolution frame, the selection flashes once, and a thumbnail flies to the element flyTo returns, so the reader sees where it went. A region too small to read keeps Capture off and says so; a blocked capture shows error in place of the selection. It is not tied to a composer: use it for bug reports, annotations or anything that needs part of a screen.

Examples

States

ProReady to drag, a region selected with its size, too small to capture, capture blocked by the browser, and the result attached with a note.

Props

PropTypeNotes
src, darkSrc, altstringThe screen frame, a dark theme version, and what it shows
active, defaultActive, onActiveChangebooleanSelecting. Cancel and capture turn it off
rect, defaultRect, onRectChange{ x, y, w, h } | nullThe selection in fractions of the frame
onCapture({ dataUrl, rect }, from: DOMRect) => voidA PNG crop and the region in frame pixels
flyTo() => HTMLElement | nullWhere the thumbnail lands
minSizenumberSmallest region in frame pixels. Default 24
errorReactNodeShown instead of the selection, with how to fix it
labelsPartial<RegionCaptureLabels>Every string, for translation

Keyboard

KeyAction
Tab to the frame, then EnterStart with a box in the middle
Arrow keys, with ShiftMove the selection 1 or 10 pixels
Alt with arrow keysResize from the end and bottom edges
EnterCapture
EscapeCancel

Accessibility

  • The selection is a button named by its size in pixels, described by the keyboard instructions.
  • A hidden button appears on focus to start a selection without a pointer.
  • The handles are pointer conveniences; everything they do is also on the keyboard.
  • A blocked capture is announced as text with the fix, never only a dimmed frame.

Motion

The selection follows the pointer with no easing. On capture it flashes once and a thumbnail travels to its destination in 480 ms on the kit's ease out. Under reduced motion there is no flash and no flight; the capture lands at once.