Artifact Panel
ProThe side panel for what an agent made, code or a document, with a title, versions, copy, download and close.
Playground
1export function UsageSummary() {2return (3<div className="rounded-xl border border-border bg-card p-4">4<p className="text-sm text-text-secondary">Requests this month</p>5<p className="text-2xl font-semibold">1,842</p>6<p className="text-sm text-text-secondary">Cost $69.98</p>7<p className="text-xs text-text-tertiary">Up 12% on last month</p>8</div>9)10}
1export function UsageSummary() {2return (3<div className="rounded-xl border border-border bg-card p-4">4<p className="text-sm text-text-secondary">Requests this month</p>5<p className="text-2xl font-semibold">1,842</p>6<p className="text-sm text-text-secondary">Cost $69.98</p>7<p className="text-xs text-text-tertiary">Up 12% on last month</p>8</div>9)10}
What changed
The usage summary shows the requests and the cost of the month in one card.
- Requests: 1,842 this month
- Cost: $69.98
- Change: up 12% on last month
What changed
The usage summary shows the requests and the cost of the month in one card.
- Requests: 1,842 this month
- Cost: $69.98
- Change: up 12% on last month
Installation
Artifact Panel comes with WunderUI Core and Pro, in the package from your plan. See the plans.
Then import what you need:
import { ArtifactPanel, ArtifactChip } from "@wunderui/react"Then use it:
import { ArtifactPanel } from "@wunderui/react"
const source = "export function UsageSummary() {\n return <p>1,842 requests</p>\n}"
export function Artifact() {
return (
<ArtifactPanel
title="usage-summary.tsx"
meta="Code · edited 2 min ago"
code={source}
onCopy={() => navigator.clipboard.writeText(source)}
/>
)
}Expected result: You should see a bordered panel with the title, the meta line and a copy button, and the code with line numbers below.
When to use
Use Artifact Panel for
- A file, component or draft that an agent made, next to the chat
- Showing the versions of something the agent changed over several turns
- Copying or downloading what the agent made
Use something else for
- Code Block for a snippet inside a message, with its own copy button
- Diff View for the lines an edit tool call changed
- Sheet for a panel that slides over the page and takes the focus until it is closed
Content
Pass code for a code view with line numbers, or children for a document. Long lines scroll sideways inside the panel.
1export function UsageSummary() {2return (3<div className="rounded-xl border border-border bg-card p-4">4<p className="text-sm text-text-secondary">Requests this month</p>5<p className="text-2xl font-semibold">1,842</p>6<p className="text-sm text-text-secondary">Cost $69.98</p>7<p className="text-xs text-text-tertiary">Up 12% on last month</p>8</div>9)10}
What changed
The usage summary shows the requests and the cost of the month in one card.
- Requests: 1,842 this month
- Cost: $69.98
- Change: up 12% on last month
1export function UsageSummary() {2return (3<div className="flex flex-col gap-1 rounded-xl border border-border bg-card p-4 text-sm text-text-secondary shadow-none transition-colors duration-fast ease-entrance hover:bg-bg-page">4<p className="text-2xl font-semibold text-foreground">1,842 requests, $69.98, up 12% on last month</p>5</div>6)7}
Actions
A button is drawn only when you pass its handler, so a panel can offer copy alone, or nothing at all.
1export function UsageSummary() {2return (3<div className="rounded-xl border border-border bg-card p-4">4<p className="text-sm text-text-secondary">Requests this month</p>5<p className="text-2xl font-semibold">1,842</p>6</div>7)8}
1export function UsageSummary() {2return (3<div className="rounded-xl border border-border bg-card p-4">4<p className="text-sm text-text-secondary">Requests this month</p>5<p className="text-2xl font-semibold">1,842</p>6</div>7)8}
1export function UsageSummary() {2return (3<div className="rounded-xl border border-border bg-card p-4">4<p className="text-sm text-text-secondary">Requests this month</p>5<p className="text-2xl font-semibold">1,842</p>6</div>7)8}
1export function UsageSummary() {2return (3<div className="rounded-xl border border-border bg-card p-4">4<p className="text-sm text-text-secondary">Requests this month</p>5<p className="text-2xl font-semibold">1,842</p>6</div>7)8}
1export function UsageSummary() {2return (3<div className="rounded-xl border border-border bg-card p-4">4<p className="text-sm text-text-secondary">Requests this month</p>5<p className="text-2xl font-semibold">1,842</p>6</div>7)8}
Versions
With two or more versions the header shows a switch. The panel reports the choice, and you hold the version and swap the content.
1export function UsageSummary() {2return (3<div className="rounded-xl border border-border bg-card p-4">4<p className="text-sm text-text-secondary">Requests this month</p>5<p className="text-2xl font-semibold">1,842</p>6</div>7)8}
1export function UsageSummary() {2return (3<div className="rounded-xl border border-border bg-card p-4">4<p className="text-sm text-text-secondary">Requests this month</p>5<p className="text-2xl font-semibold">1,842</p>6<p className="text-sm text-text-secondary">Cost $69.98</p>7</div>8)9}
1export function UsageSummary() {2return (3<div className="rounded-xl border border-border bg-card p-5">4<p className="text-sm text-text-secondary">Requests this month</p>5<p className="text-3xl font-semibold">1,842</p>6<p className="text-sm text-text-secondary">Cost $69.98</p>7<p className="text-xs text-text-tertiary">Up 12% on last month</p>8</div>9)10}
Height
The panel has no height of its own. Give it one and the code view scrolls inside while the header stays in place.
1export function UsageSummary() {2return (3<div className="rounded-xl border border-border bg-card p-4">4<p className="text-sm text-text-secondary">Requests this month</p>5<p className="text-2xl font-semibold">1,842</p>6<p className="text-sm text-text-secondary">Cost $69.98</p>7<p className="text-xs text-text-tertiary">Up 12% on last month</p>8</div>9)10}
1export function UsageSummary() {2return (3<div className="rounded-xl border border-border bg-card p-4">4<p className="text-sm text-text-secondary">Requests this month</p>5<p className="text-2xl font-semibold">1,842</p>6<p className="text-sm text-text-secondary">Cost $69.98</p>7<p className="text-xs text-text-tertiary">Up 12% on last month</p>8</div>9)10}
What changed
The usage summary shows the requests and the cost of the month in one card.
- Requests: 1,842 this month
- Cost: $69.98
- Change: up 12% on last month
Artifact chip
ArtifactChip is the card under an assistant message that opens an artifact: a tinted tile for a document or code, the title, a kind and version line and an arrow. selected marks the artifact the panel shows and reads Open from 1024 px.
Shadow
The panel has a subtle shadow (shadow-xs) by default; pass shadow-none in className to flatten it.
The panel carries shadow-xs by default.
Keyboard interactions
The header holds native buttons and one Segment, and the code view is a focusable region.
- TaborShift+Tab
- Moves through the version switch (one stop, on the selected version), , , and then the code view. A document has no stop of its own; anything focusable in it is reached in order.
- ←or→
- In the version switch: selects the previous or next version and calls .
- HomeorEnd
- In the version switch: selects the first or last version.
- EnterorSpace
- Presses the focused button: copy, download or close.
- ↑or↓
- In the code view, which is focusable: scrolls it vertically; ← and → scroll long lines sideways.
Escape does nothing: the panel is not a dialog and has no open state. Close it on Escape where you hold the open state.
Behavior and motion
What the panel does with content, versions, actions, height and assistive technology.
- Not a dialog
- The panel is a plain section with no role, name or focus trap. Opening, closing, focus and Escape are yours, so give its wrapper a region role and a label for focus to land on.
- Code or document
- Pass code for a view with line numbers, or children for a document; if both, code wins. An empty string counts as code, and there is no syntax colouring or wrapping.
- Versions
- The switch shows for two or more versions. The panel never loads one: swap the code or content in your change handler, or the content stays while the highlight moves.
- Actions
- Each button appears when its handler is passed. The panel never reads the clipboard, never makes a file and shows no feedback after a press.
- Height and width
- The panel fills its container and grows with its content. Give it a height and the content scrolls inside while the header stays; there is no resize handle, so width is your layout's job.
- Long titles and narrow widths
- The title is cut with an ellipsis. The header wraps, so on a narrow width the version switch and the actions move below the title.
- No loading or error state
- The panel does not know an artifact is being written or has failed. Pass a status line with skeleton rows, or an alert, as content, and omit the handlers until the artifact exists.
- Assistive technology
- The code view is a region named Code and its line numbers are hidden from assistive technology. The switch is named Version, the buttons Copy, Download and Close panel, and the title is plain text.
- Motion
- The panel has no motion of its own. Icon buttons press with a small scale that is off under reduced motion, and the version switch changes at once.
- Reduced motion
- There is nothing to reduce. If you animate opening and closing, follow your layout's motion rules and respect reduced motion.
Anatomy
The figure marks a code panel with three versions and all three actions. The header wraps below the title on a narrow width.
1export function UsageSummary() {2return (3<div className="rounded-xl border border-border bg-card p-4">4<p className="text-sm text-text-secondary">Requests this month</p>5<p className="text-2xl font-semibold">1,842</p>6</div>7)8}
- 1data-slot="artifact-panel"
A bordered section with a 16 px radius, as wide as its container and as tall as its content unless you set a height. It has no role or name and is not a dialog.
- 2
The title in 14 px semibold on one line, cut with an ellipsis, and an optional meta line in 12 px secondary text. The title is not a heading.
- 3Optional
A small Segment named Version, shown when there are two or more versions. It reports the choice; swapping the content is up to you.
- 4Optional
Ghost icon buttons named Copy, Download and Close panel. Each shows only when you pass its handler.
- 5
With code: a monospace view with line numbers, no wrapping, focusable as a region named Code. Without code: your content in a padded column of 14 px secondary text.
Best practices
- Do
Hold the version in your code: pass the current version, the change handler and the matching code. Without them the switch moves its own highlight and shows the same content.
- Do
Move focus into the panel when it opens and back to the opener when it closes, since the panel does neither. Make its wrapper a labelled region and close it on Escape.
- Do
Answer copy and download yourself. The panel gives no feedback, so say Copied usage-summary.tsx in a status line, or say that the browser refused.
- Do
Show loading and failure in the content (a status line with skeleton rows, or an alert with a retry) and leave out handlers that cannot work yet: a button without a handler is not drawn.
- Do
Give the panel a height where it sits in a fixed column. The code view and a document then scroll inside while the header stays in place.
- Don’t
Don't put the panel in a dialog just to open it. It is a region beside the content, not a modal, and it does not trap focus.
- Don’t
Don't expect Preview and Code tabs. Compose Tabs inside the panel, as the Examples tab does.
- Don’t
Don't pass an empty string as code for a document that has not arrived. It draws one empty numbered line and ignores the content.
API reference
ArtifactPanel is a plain component, so the table lists every prop.
A bordered section with a 16 px radius, as wide as its container and as tall as its content unless you set a height. It has no role or name and is not a dialog.
| Prop | Type | Default | Description |
|---|---|---|---|
| title required | ReactNode | — | The name of the artifact, on one line in the header. Required. |
| meta | ReactNode | — | A second line under the title, for the kind and who edited it and when. |
| versions | string[] | [] | The names of the versions, for example . With two or more the header draws a version switch. Default: none. |
| version | string | — | The selected version, for a controlled switch. Without it the switch keeps its own selection, starting on the last version. |
| onVersionChange | (v) => void | — | Called with the name of the version the person chose. Swap or the children here: the panel does not. |
| code | string | — | A string drawn as code with line numbers. Omit it and pass for a document. wins when both are passed. |
| children | ReactNode | — | The document, drawn in a padded column of 14 px secondary text when is not set. |
| onCopy | () => void | — | Draws the button. The panel copies nothing itself: write the clipboard here and say that it worked. |
| onDownload | () => void | — | Draws the button. The panel makes no file itself. |
| onClose | () => void | — | Draws the button. The panel does not unmount itself. |
| className | string | — | Extra classes for the panel, for example a width or a height such as . |
| Prop | Type | Default | Description |
|---|---|---|---|
| title required | ReactNode | — | |
| kind | "document" | "code" | "document" | Sets the icon and the tile colour: a written document or a piece of code. |
| meta | ReactNode | — | The line under the title, for example . |
| onOpen | () => void | — | |
| selected | boolean | — | The artifact the panel currently shows. |
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("artifact-panel")The full library index for assistants is at /llms.txt.
Related components
@@ -12,7 +12,8 @@ export async function sendReminders()
1212const overdue = invoices.filter(isOverdue)1313for (const invoice of overdue) {14−Removed:if (daysSince(invoice.dueDate) < 7) continue14+Added:if (daysSince(invoice.dueDate) < 3) continue15+Added:if (invoice.reminderSentAt) continue1516await send({1617to: invoice.customer.email,17−Removed:subject: "Payment reminder",18+Added:subject: `Invoice ${invoice.number} is overdue`,1819})AI & Agents4 stylesProDiff ViewThe result of an edit tool call: file, added and removed lines, and the changed code.Sources
5 pinned- 1q3-report.pdfFile · 2.4 MB
- 2Pricing, WunderUIwunderui.com · web page
- 3Billing migration planDocument · edited by Priya Raman
- 4#release-notesChannel · 128 messages
- 5Changelog, WunderUIwunderui.com · web page
AI & Agents5 stylesProSource ListNumbered sources pinned to a chat; citations like [1] in answers point here.