Artifact
What the agent made, as a card in the chat. Open it and the same object grows to fill the chat pane; drag the version scrubber and the document changes under your thumb.
npx shadcn@latest add @captain/artifactRewrite 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.
Artifact is a Pro component
The demo and the docs are free. The source comes with Pro, through this page, the shadcn CLI and the MCP.
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
| Prop | Type | Default | What it does |
|---|---|---|---|
| title | string | The artifact's name. | |
| meta | string | Kind and size, e.g. Doc, 60 words. | |
| versions | ArtifactVersion[] | { label, when, note, content }. The last one opens first. | |
| icon | IconName | "file" | Leading glyph in a well. |
| open / defaultOpen | boolean | Expanded state. Pair open with onOpenChange. | |
| <ins> in content | element | Marks 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 modal dialog.
- Focus moves to Close on open and back to the card on close.
- 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.