# Artifact expand

An artifact that opens out of its message: the inline card grows into the side panel.

Also called: expand to panel, card to panel transition.

> 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: Artifacts that open out of the message. Open the inline card and it grows into the side panel; close it and the panel shrinks back into the card. Preview: https://chatcn.dev/preview/artifact-expand-demo

The inline card in the conversation is the panel, small. Open it and the card grows into the side panel, travelling to its place and size while its corners and contents settle; close it and the panel shrinks back into the card. The panel fills the end side of the nearest positioned ancestor.

## Installation

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

## Usage

```tsx
import { ArtifactExpand } from "@/components/ui/chatcn/pro/artifact-expand"

<main className="relative">
  <ArtifactExpand title="Pricing section" kind="React component" open={open} onOpenChange={setOpen} preview={<Thumb />}>
    <PricingSection />
  </ArtifactExpand>
</main>
```

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `title` / `kind` | `string` |  |
| `open` / `onOpenChange` | `boolean` |  |
| `preview` | `ReactNode` | Inside the inline card |
| `children` | `ReactNode` | The artifact, in the panel |

## Keyboard

| Key | Action |
| --- | --- |
| `Escape` | Close the panel |

## Accessibility

- The panel is a labelled dialog; closing returns focus to the card.

## Motion

- A 460 ms transform from the card's box to the panel's and back. Reduced motion: it swaps.

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