Artifact Panel
The panel an AI app opens beside the chat to show what it made: a page preview, a document, the code behind it. A title, a version switcher, your own actions, a close button and Preview/Code views, around a body you fill with anything.
Docked or overlay
On a wide screen the panel is an <aside> in the page flow, named by its title, so it drops into aResizable pane or a grid column and fills it. Below overlayBelow (768px by default) it becomes a<dialog> opened with showModal(): a full-height sheet from the inline end, with the focus trap, Escape, backdrop and focus return all coming from the browser, likeDialog andSheet.
The switch is a viewport media query, not a container query, because it changes the element and how focus behaves, which CSS can't do. It's also the right question: whether there's room beside the chat on this screen. A narrow Resizable pane on a desktop stays docked. Passpresentation="docked" or "overlay" to choose yourself. Crossing the breakpoint swaps the element, so an iframe preview reloads once.
Status and versions
status="streaming" shows a small pulsing dot and "Generating…" beside the title, and marks the panelaria-busy; "error" shows "Generation failed". The text sits in a polite live region that's there from the start, so the change is announced. With versionCount above 1 the header gets previous/next buttons and a "v3 of 5" readout. Every built-in string goes through labels.
Usage
Usage
<Resizable defaultSplit={38}>
<Chat />
<ArtifactPanel
title="coffee-landing.html"
open={open}
onOpenChange={setOpen}
status={streaming ? "streaming" : "ready"}
version={version}
versionCount={versions.length}
onVersionChange={setVersion}
actions={<Button variant="ghost" size="sm" aria-label="Copy code" iconStart={<CopyIcon />} onClick={copy} />}
views={[
{ value: "preview", label: "Preview", content: <iframe title="Preview" sandbox="" srcDoc={html} /> },
{ value: "code", label: "Code", content: <CodeBlock language="html" code={html} /> },
]}
/>
</Resizable><kernel-resizable default-split="38">
<div>…chat…</div>
<kernel-artifact-panel title="coffee-landing.html" open status="streaming" version="3" version-count="3">
<kernel-button slot="actions" variant="ghost" size="sm" aria-label="Copy code">…</kernel-button>
<kernel-artifact-view value="preview" label="Preview">
<iframe title="Preview" sandbox="" srcdoc="…"></iframe>
</kernel-artifact-view>
<kernel-artifact-view value="code" label="Code">
<kernel-code-block language="html">…</kernel-code-block>
</kernel-artifact-view>
</kernel-artifact-panel>
</kernel-resizable>Playground
Toggle every adjustable prop and watch the component, and the code, update live.
Usage
<ArtifactPanel
title="quarterly-report.md"
presentation="docked"
open={open}
onOpenChange={setOpen}
version={version}
versionCount={3}
onVersionChange={setVersion}
views={[
{ value: "preview", label: "Preview", content: <Preview /> },
{ value: "source", label: "Source", content: <CodeBlock code={source} /> },
]}
/><kernel-artifact-panel
title="quarterly-report.md"
open
presentation="docked"
version="3"
version-count="3"
>
<kernel-artifact-view value="preview" label="Preview">…</kernel-artifact-view>
<kernel-artifact-view value="source" label="Source">…</kernel-artifact-view>
</kernel-artifact-panel>Props
| Prop | Type | Default | Notes |
|---|---|---|---|
title | ReactNode | Required | The artifact's name. Rendered as a real heading and used as the panel's accessible name in both presentations. |
headingLevel | 2 | 3 | 4 | 2 | Level of the title heading in docked mode. Defaults to 2. A modal overlay is its own document context, so it always uses h2. |
open | boolean | true | Whether the panel is showing. Defaults to true, the usual case for a docked panel the host mounts and unmounts itself. |
onOpenChange | (open: boolean) => void | — | Close button, Escape and backdrop clicks (overlay) ask for false. |
presentation | "auto" | "docked" | "overlay" | "auto" | "docked": an <aside> in the page flow — put it in a Resizable pane or a grid column. "overlay": a modal <dialog> sliding in from the inline end. "auto" (default) is docked, and overlay when the viewport is narrower than overlayBelow. |
overlayBelow | number | 768 | Viewport width in px below which "auto" becomes an overlay. Defaults to 768. |
status | "ready" | "streaming" | "error" | "ready" | "streaming" while the model is still writing the artifact, "error" when it failed. Shown as a small dot and a short line of text by the title, announced politely. |
version | number | — | The version on show, 1-based. With versionCount above 1 the header gets previous/next buttons and a "v3 of 5" readout. |
versionCount | number | — | — |
onVersionChange | (version: number) => void | — | — |
actions | ReactNode | — | Your own header controls — copy, download, open in a new window. Rendered before the built-in close button. |
views | ArtifactPanelView[] | — | Views of the artifact ("Preview", "Code"), switched with Kernel's Tabs. Without views, children is the body. |
view | string | — | — |
defaultView | string | — | — |
onViewChange | (view: string) => void | — | — |
children | ReactNode | — | — |
showCloseButton | boolean | true | Hide the built-in close button. Escape still closes an overlay. |
labels | Partial<ArtifactPanelLabels> | — | — |
className | ClassNameValue<ArtifactPanelState> | — | A class string, or a function of the component's state that returns one. |
Web Components
| Tag | Attributes | Events |
|---|---|---|
<kernel-artifact-panel> | title, heading-level, open, presentation, overlay-below, status, version, version-count, view, label-close, label-previous-version, label-next-version, label-version, label-versions, label-views, label-streaming, label-error | viewchange, versionchange |
<kernel-artifact-view> | — | — |
Accessibility
- Docked, it's a complementary landmark (
<aside>) named by its title heading, which is a realh2(setheadingLevelto fit your outline). - As an overlay, it's a modal
<dialog>: the page behind is inert, focus is trapped inside, Escape and the close button close it, and focus returns to whatever opened it. - Views are Kernel's Tabs: arrow keys move between tabs and inactive panels are
hidden. - An iframe preview needs its own
title. Give itsandboxtoo: generated code shouldn't run with your page's permissions. - The status dot keeps moving, slower, under reduced motion; it's the only sign that generation is still running. The overlay fades instead of sliding.