Компоненты
- Accordion
- Alert
- Alert Dialog
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Button
- Calendar
- Card
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Command
- Date Picker
- Dialog
- DrawerNew
- Empty
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Input Group
- Kbd
- Label
- Menu
- Meter
- Number Field
- OTP FieldNew
- Pagination
- Popover
- Preview Card
- Progress
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Toolbar
- Tooltip
AI Components
- AI Components
- Chat Conversation
- Chat Message
- Chat Response
- Chat Suggestion
- Chat Prompt Input
- Chat Attachments
- Chat Code Block
- Chat Image
- Chat Inline Citation
- Chat Reasoning
- Chat Sources
- Chat Actions
- Chat Context
- Chat Loader
- Chat Task
- Chat Tool
- Chat Web Preview
- Chat Snippet
- Chat Terminal
- Chat Stack Trace
- Chat Test Results
- Chat File Tree
- Chat Environment Variables
- Chat Audio Player
- Chat Transcription
- Chat Speech Input
- Chat Mic Selector
- Chat Voice Selector
- Chat Agent
- Chat Persona
- Chat Connection
- Chat Queue
- Chat Checkpoint
- Chat Confirmation
- Chat Artifact
- Chat JSX Preview
- Chat Schema Display
- Chat Package Info
- Chat Commit
- Chat Plan
- Chat Panel
- Chat Open In Chat
- Chat Sandbox
- Chat Model Selector
- Chat Canvas
- Chat Node
- Chat Edge
Resources
Chat Artifact
Side-panel контейнер для сгенерированных артефактов — кода, документов, image-превью.
page.tsx — Cache Components
Generated by the assistant · ~32 lines · TSX
page.tsx
// app/products/[id]/page.tsx"use cache";
import { cacheTag } from "next/cache";
export default async function ProductPage({ params }) { const { id } = await params; cacheTag(`product:${id}`); const product = await db.product.get(id); return <Product data={product} />;}v3 · auto-saved 14:02
import { DownloadIcon, ExternalLinkIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
ChatArtifact,
ChatArtifactAction,
ChatArtifactActions,
ChatArtifactClose,
ChatArtifactContent,
ChatArtifactDescription,
ChatArtifactFooter,
ChatArtifactHeader,
ChatArtifactInfo,
ChatArtifactTitle,
} from "@/components/ui/chat-artifact";
import {
ChatCodeBlock,
ChatCodeBlockActions,
ChatCodeBlockCopyButton,
ChatCodeBlockFilename,
ChatCodeBlockHeader,
} from "@/components/ui/chat-code-block";
const code = `// app/products/[id]/page.tsx
"use cache";
import { cacheTag } from "next/cache";
export default async function ProductPage({ params }) {
const { id } = await params;
cacheTag(\`product:\${id}\`);
const product = await db.product.get(id);
return <Product data={product} />;
}`;
export default function Particle() {
return (
<div className="h-[520px] w-full max-w-2xl p-4">
<ChatArtifact>
<ChatArtifactHeader>
<ChatArtifactInfo>
<ChatArtifactTitle>page.tsx — Cache Components</ChatArtifactTitle>
<ChatArtifactDescription>
Generated by the assistant · ~32 lines · TSX
</ChatArtifactDescription>
</ChatArtifactInfo>
<ChatArtifactActions>
<ChatArtifactAction label="Download">
<DownloadIcon aria-hidden="true" />
</ChatArtifactAction>
<ChatArtifactAction label="Open in new tab">
<ExternalLinkIcon aria-hidden="true" />
</ChatArtifactAction>
<ChatArtifactClose />
</ChatArtifactActions>
</ChatArtifactHeader>
<ChatArtifactContent>
<div className="p-3">
<ChatCodeBlock code={code} language="tsx" showLineNumbers>
<ChatCodeBlockHeader>
<ChatCodeBlockFilename>page.tsx</ChatCodeBlockFilename>
<ChatCodeBlockActions>
<ChatCodeBlockCopyButton />
</ChatCodeBlockActions>
</ChatCodeBlockHeader>
</ChatCodeBlock>
</div>
</ChatArtifactContent>
<ChatArtifactFooter>
<span className="text-muted-foreground text-xs">
v3 · auto-saved 14:02
</span>
<Button size="sm">Apply patch</Button>
</ChatArtifactFooter>
</ChatArtifact>
</div>
);
}
Installation
pnpm dlx shadcn@latest add @jenny/chat-artifact
Usage
import {
ChatArtifact,
ChatArtifactAction,
ChatArtifactActions,
ChatArtifactClose,
ChatArtifactContent,
ChatArtifactDescription,
ChatArtifactFooter,
ChatArtifactHeader,
ChatArtifactInfo,
ChatArtifactTitle,
} from "@/components/ui/chat-artifact";
<ChatArtifact className="h-[600px] w-[480px]">
<ChatArtifactHeader>
<ChatArtifactInfo>
<ChatArtifactTitle>Landing page draft</ChatArtifactTitle>
<ChatArtifactDescription>
Hero · Features · Pricing · Footer
</ChatArtifactDescription>
</ChatArtifactInfo>
<ChatArtifactActions>
<ChatArtifactAction label="Download">
<DownloadIcon />
</ChatArtifactAction>
<ChatArtifactAction label="Open in new window">
<ExternalLinkIcon />
</ChatArtifactAction>
<ChatArtifactClose onClick={close} />
</ChatArtifactActions>
</ChatArtifactHeader>
<ChatArtifactContent>
{/* Code, web-preview, image, schema — что угодно */}
<ChatJsxPreview jsx={modelJsx} components={{ Button }} />
</ChatArtifactContent>
<ChatArtifactFooter>
<span className="text-muted-foreground text-xs">v3 · auto-saved</span>
<Button size="sm">Apply changes</Button>
</ChatArtifactFooter>
</ChatArtifact>API
| Component | Описание |
|---|---|
ChatArtifact | Корневой flex-column контейнер с border + shadow. |
ChatArtifactHeader | Border-bottom строка с info-слотом и actions. |
ChatArtifactInfo / ChatArtifactTitle / ChatArtifactDescription | Заголовок + подпись. |
ChatArtifactActions / ChatArtifactAction / ChatArtifactClose | Icon-кнопки. |
ChatArtifactContent | Scrollable body — занимает оставшуюся высоту. |
ChatArtifactFooter | Опциональная footer-строка для status / submit-кнопок. |
On This Page