Region capture (Pro)
ProIncluded in $99Pick 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.
On this page
Installation
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
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
Props
| Prop | Type | Notes |
|---|---|---|
src, darkSrc, alt | string | The screen frame, a dark theme version, and what it shows |
active, defaultActive, onActiveChange | boolean | Selecting. Cancel and capture turn it off |
rect, defaultRect, onRectChange | { x, y, w, h } | null | The selection in fractions of the frame |
onCapture | ({ dataUrl, rect }, from: DOMRect) => void | A PNG crop and the region in frame pixels |
flyTo | () => HTMLElement | null | Where the thumbnail lands |
minSize | number | Smallest region in frame pixels. Default 24 |
error | ReactNode | Shown instead of the selection, with how to fix it |
labels | Partial<RegionCaptureLabels> | Every string, for translation |
Keyboard
| Key | Action |
|---|---|
| Tab to the frame, then Enter | Start with a box in the middle |
| Arrow keys, with Shift | Move the selection 1 or 10 pixels |
| Alt with arrow keys | Resize from the end and bottom edges |
| Enter | Capture |
| Escape | Cancel |
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.