Skip to content
Sign in
App builderElement pickerMenu

Element pickerPro

Pick elements on a live preview the way a design tool does: tag, name, size and padding on hover, a breadcrumb of the element tree, arrow keys to walk it, and Cmd L to attach the element to the next message.

ProA ceramics studio booking page. Hover to see tag, size and padding, click to select, walk the tree with the arrow keys and press Cmd L to attach the element to the message.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/element-picker

Usage

tsx
import { ElementPicker } from "@/components/ui/chatcn/pro/element-picker"

<ElementPicker value={path} onValueChange={setPath} onAddToChat={attach} inChat={attachedPaths}>
  <GeneratedApp />
</ElementPicker>

Wrap the rendered app. A selection is a child index path such as 0.2.1, so it survives re-renders and serializes. Elements are named from data-builder-name, then aria-label, then the id; pass getName to map them to your source components. While picking, links and buttons in the preview do not fire.

Examples

States

ProA deep selection with a folded path, nothing selected, picking off, and disabled while the agent edits.

Props

PropTypeNotes
value, defaultValue, onValueChangestring | nullSelected path; the callback also gets the PickedElement
active, defaultActive, onActiveChangebooleanPicking on or off. Default on
onAddToChat(element: PickedElement) => voidCmd or Ctrl L, or Add to chat
inChatstring[]Paths already attached; they wear a dashed outline
getName(element) => string | undefinedFriendly names for the chip and breadcrumb
showSpacingbooleanHatch the hovered element's padding. Default true
breadcrumbbooleanThe bar with the path and actions. Default true
disabled, disabledReasonboolean, ReactNodeFor example while the agent edits the page

Keyboard

KeyAction
ArrowUpSelect the parent
ArrowDownSelect the first child
ArrowLeft ArrowRightPrevious and next sibling, mirrored in RTL
EnterSelect the hovered element
Cmd L Ctrl LAdd the selection to the chat
EscapeClear the selection, then stop picking

Accessibility

  • The preview is a focusable group that names the selection and describes the keys. Every selection and every attach is announced in a polite live region with the tag, name and size.
  • The breadcrumb is a navigation landmark of buttons, so the tree is reachable without a pointer.
  • Overlays are hidden from assistive tech; the same facts are in the label and the announcement.

Motion

  • The hover box follows the pointer with no transition, so it never lags. The selection appears with a 120 ms scale and fade from the free preview selection.
  • Keyboard moves jump without animation. Reduced motion keeps the fade only.