Skip to content
Sign upPro
Chat layoutsCopilot drawerMenu

Copilot drawer (Pro)

ProIncluded in $99

An in-app copilot beside the page: it shows what it reads as chips, rings each part on the page, lets you leave parts out, and docks or floats.

ProA freight shipment held at customs, with the copilot docked beside it: it reads the page, then a charge you pick.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/copilot-drawer

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 { CopilotDrawer, CopilotDrawerTrigger } from "@/components/ui/chatcn/pro/copilot-drawer"

<CopilotDrawer
  messages={messages}
  status={status}
  onSend={(text, { context }) => ask(text, context)}
  context={[
    { id: "invoice", label: "INV-2081", kind: "page", target: "summary" },
    { id: "lines", label: "Line items", target: "lines" },
  ]}
>
  <PageHeader actions={<CopilotDrawerTrigger />} />
  <section data-copilot-target="summary">…</section>
  <section data-copilot-target="lines">…</section>
</CopilotDrawer>

Wrap the page in it; the page keeps working while the drawer is open. Under the input, chips show exactly what the copilot will read. Pointing at a chip draws a ring around the matching data-copilot-target on the page, and the ring glides from part to part rather than blinking, so it is always clear where it looks. Clicking a chip leaves that part out (struck through, with an eye off mark), and onSend only receives what is left in. New context, such as a row the reader selects, flashes its ring once. The drawer either docks beside the page and pushes it or floats over it; on a narrow host it always floats as a full sheet. Drag the edge, or focus it and use the arrow keys, to resize; width and mode are remembered under storageKey. Mod I toggles it.

Examples

States

ProClosed, open with starters, one part left out, floating over the page, a failed answer with Try again, and disabled.

Props

PropTypeNotes
childrenReactNodeThe host page
messagesChatcnMessage[]The thread, in the kit's message contract
status, error, onStop, onRetry"ready" | "submitted" | "streaming" | "error"Send becomes Stop while it streams; an error offers Try again
value, defaultValue, onValueChangestringThe draft, controlled or not
onSend(text, { context }) => voidcontext holds only the items left in
contextCopilotContextItem[]{ id, label, detail?, kind?, target? }; target matches data-copilot-target
excluded, defaultExcluded, onExcludedChangestring[]Ids of the parts left out
open, defaultOpen, onOpenChangeboolean
mode, defaultMode, onModeChange"push" | "overlay"Docked or floating
width, defaultWidth, onWidthChange, minWidth, maxWidthnumberIn px. Default 384
storageKeystring | nullWhere width and mode are remembered; null turns it off
suggestionsstring[]Starter questions in the empty state
hotkey, hotkeyTargetstring | nullDefault mod+i
disabledboolean
labelsPartial<CopilotDrawerLabels>Every string, for translation

Keyboard

KeyAction
Mod IOpen or close the drawer
EscapeClose it, focus back where it was opened from
Arrow toward the page, away from itResize by 16 px, with Shift by 64 px
Home, End, Enter on the edgeNarrowest, widest, back to the default width
Enter, Shift EnterSend, new line

Accessibility

  • The drawer is a labelled complementary region; opening it moves focus to the input and closing returns it.
  • The edge is a separator with its current, minimum and maximum width.
  • Each chip says what clicking does: Leave out Charges, or Include Charges.
  • How many parts it reads is in words under the input, so the ring is never the only signal.

Motion

The drawer slides in from the inline end on the kit's spring and the docked page makes room in the same motion. The page ring glides between parts in 220 ms. Under reduced motion the drawer fades, and the ring jumps.