# 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 a [Resizable](/components/resizable) 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, like [Dialog](/components/dialog) and [Sheet](/components/sheet).

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. Pass `presentation="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 panel `aria-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

## Playground

Toggle every adjustable prop and watch the component, and the code, update live.

## 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 real `h2` (set `headingLevel` to 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](/components/tabs): arrow keys move between tabs and inactive panels are `hidden`.
- An iframe preview needs its own `title`. Give it `sandbox` too: 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.
