Captain UI

Artifact

What the agent made, as a card in the chat. Open it and the same object grows into the pane, leaving its imprint in the chat; drag the version scrubber and the document changes under your thumb.

npx shadcn@latest add @captain/artifact
Pro

Rewrite the pricing copy around spend caps. Keep it under 80 words.

I led with the cap and added what happens when an agent hits it. Three versions, the last with your edits.

Usage

import { Artifact } from "@/components/ui/artifact"

<div className="relative h-full">  {/* the chat pane */}
  <Artifact title="Pricing page copy" meta="Doc, 60 words" versions={versions} />
</div>

Props

PropTypeDefaultWhat it does
titlestringThe artifact's name.
metastringKind and size, e.g. Doc, 60 words.
versionsArtifactVersion[]{ label, when, note, content }. The last one opens first.
iconIconName"file"Leading glyph in a well.
open / defaultOpenbooleanExpanded state. Pair open with onOpenChange.
panelClassNamestring"inset-3"Where the open document sits in the positioned parent, e.g. a right-hand pane beside the chat.
modalbooleantruefalse opens it as a side pane: no scrim, and the chat stays usable.
<ins> in contentelementMarks what changed in a version; shown as a soft accent tint.

Keyboard

Enter
Open
Esc
Close and return focus to the card
← → on the scrubber
Previous or next version

Accessibility

  • The card is a button with aria-haspopup=dialog; the panel is a labelled dialog, modal unless modal={false}.
  • Focus moves to Close when someone opens it and back to the card on close; opening by default never steals focus on load.
  • The scrubber is a slider whose value text names the version and its time.
  • It fills its nearest positioned parent, so give the chat pane position: relative.