Skip to content
WunderUI

Artifact Panel

Pro

The side panel for what an agent made, code or a document, with a title, versions, copy, download and close.

Playground

usage-summary.tsxCode · edited 2 min ago
export function UsageSummary() {
return (
<div className="rounded-xl border border-border bg-card p-4">
<p className="text-sm text-text-secondary">Requests this month</p>
<p className="text-2xl font-semibold">1,842</p>
<p className="text-sm text-text-secondary">Cost $69.98</p>
<p className="text-xs text-text-tertiary">Up 12% on last month</p>
</div>
)
}

Installation

Artifact Panel comes with WunderUI Core and Pro, in the package from your plan. See the plans.

Then import what you need:

tsx
import { ArtifactPanel, ArtifactChip } from "@wunderui/react"

Then use it:

tsx
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.

usage-summary.tsxCode · edited 2 min ago
export function UsageSummary() {
return (
<div className="rounded-xl border border-border bg-card p-4">
<p className="text-sm text-text-secondary">Requests this month</p>
<p className="text-2xl font-semibold">1,842</p>
<p className="text-sm text-text-secondary">Cost $69.98</p>
<p className="text-xs text-text-tertiary">Up 12% on last month</p>
</div>
)
}

Actions

A button is drawn only when you pass its handler, so a panel can offer copy alone, or nothing at all.

usage-summary.tsxCode · edited 2 min ago
export function UsageSummary() {
return (
<div className="rounded-xl border border-border bg-card p-4">
<p className="text-sm text-text-secondary">Requests this month</p>
<p className="text-2xl font-semibold">1,842</p>
</div>
)
}

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.

usage-summary.tsxCode · edited 2 min ago
export function UsageSummary() {
return (
<div className="rounded-xl border border-border bg-card p-4">
<p className="text-sm text-text-secondary">Requests this month</p>
<p className="text-2xl font-semibold">1,842</p>
</div>
)
}

Height

The panel has no height of its own. Give it one and the code view scrolls inside while the header stays in place.

usage-summary.tsxCode · edited 2 min ago
export function UsageSummary() {
return (
<div className="rounded-xl border border-border bg-card p-4">
<p className="text-sm text-text-secondary">Requests this month</p>
<p className="text-2xl font-semibold">1,842</p>
<p className="text-sm text-text-secondary">Cost $69.98</p>
<p className="text-xs text-text-tertiary">Up 12% on last month</p>
</div>
)
}

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.

Release notesDocument · v2

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.

TaborShiftTab
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.

usage-summary.tsxCode · edited 2 min ago
export function UsageSummary() {
return (
<div className="rounded-xl border border-border bg-card p-4">
<p className="text-sm text-text-secondary">Requests this month</p>
<p className="text-2xl font-semibold">1,842</p>
</div>
)
}
  • data-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.

  • 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.

  • Optional

    A small Segment named Version, shown when there are two or more versions. It reports the choice; swapping the content is up to you.

  • Optional

    Ghost icon buttons named Copy, Download and Close panel. Each shows only when you pass its handler.

  • 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.

PropTypeDefaultDescription
title requiredReactNode—The name of the artifact, on one line in the header. Required.
metaReactNode—A second line under the title, for the kind and who edited it and when.
versionsstring[][]The names of the versions, for example . With two or more the header draws a version switch. Default: none.
versionstring—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.
codestring—A string drawn as code with line numbers. Omit it and pass for a document. wins when both are passed.
childrenReactNode—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.
classNamestring—Extra classes for the panel, for example a width or a height such as .

PropTypeDefaultDescription
title requiredReactNode—
kind"document" | "code""document"Sets the icon and the tile colour: a written document or a piece of code.
metaReactNode—The line under the title, for example .
onOpen() => void—
selectedboolean—The artifact the panel currently shows.

Notes for AI

Give your coding assistant the Markdown reference instead of screenshots.

MCPget_component("artifact-panel")
InstallIncluded in Core and Pro

The full library index for assistants is at /llms.txt.