# Artifact sheet

An artifact opens as a near full height sheet and the chat steps back behind it, scaled down with rounded corners.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: Artifact sheet. Tap the patch in the reply: the sheet rises and the chat steps back. Drag it down to bring the chat forward. Preview: https://chatcn.dev/preview/artifact-sheet-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/artifact-sheet
```

## Usage

```tsx
import { ArtifactSheet } from "@/components/ui/chatcn/pro/artifact-sheet"

<ArtifactSheet
  open={open}
  onOpenChange={setOpen}
  title="createIntent.patch"
  subtitle="Patch · 1 file"
  icon={<FileDiffIcon />}
  actions={<CopyButton value={patch} label="Copy patch" />}
  content={<DiffViewer patch={patch} />}
  returnFocus={cardRef}
>
  <ChatScreen />   {/* the chat it covers */}
</ArtifactSheet>
```

Wrap the chat screen in it. When it opens, the chat scales down, drops just below the status bar and rounds its top corners over a dark backdrop, the way native apps stack a card over what opened it, so it is clear the chat is still there. The chat follows the sheet exactly: on the same spring when the sheet moves on its own, and 1:1 with the finger while it is dragged down, so pulling the sheet brings the chat forward. A flick or a pull past the threshold closes it. The header holds the artifact's name, a line under it, your actions and Close; it drags from anywhere except its buttons. The chat behind is inert while the sheet is up. In a phone frame, turn the status bar light while it is open, as the demo does.

## Examples

### States

Example: States. Open at real phone width, with a document instead of code. Preview: https://chatcn.dev/preview/artifact-sheet-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `open`, `onOpenChange` | `boolean` | Controlled |
| `title`, `subtitle`, `icon` |  | The header |
| `actions` | `ReactNode` | Buttons before Close |
| `content` | `ReactNode` | The artifact |
| `returnFocus` | `RefObject<HTMLElement>` | Usually the card that opened it |
| `children` | `ReactNode` | The screen behind |
| `labels` | `Partial<ArtifactSheetLabels>` | Every string, for translation |

## Keyboard

| Key | Action |
| --- | --- |
| Escape | Close; focus returns to the card |
| Arrow down on the grabber | Close |
| Tab | Stays inside the sheet |

## Accessibility

- The sheet is a modal dialog named by the artifact; the chat behind is inert while it is open.
- Close is a real button, so the gesture is never the only way out.

## Motion

The sheet and the chat behind move together on a critically damped spring over about 520 ms; the chat scales to 92% and rounds its corners with clip-path. Under reduced motion the sheet slides in 150 ms and the chat does not scale.

Source: https://chatcn.dev/docs/components/artifact-sheet