Components
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Command
- Context Menu
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Input Group
- Kbd
- Label
- Menu
- Menubar
- Message
- Meter
- Number Field
- OTP Field
- Pagination
- Popover
- Preview Card
- Progress
- Questionnaire
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Toolbar
- Tooltip
Shared
- Artifact
- Audio Player
- Canvas
- Chain of Thought
- Checkpoint
- Code Block
- Commit
- Connection
- Context
- Controls
- Edge
- Environment Variables
- Mic Selector
- Model Selector
- Node
- Node Toolbar
- Open in Chat
- Panel
- Plan
- Prompt Input
- Queue
- Reasoning
- Sandbox
- Schema Display
- Shimmer
- Snippet
- Sources
- Speech Input
- Stack Trace
- Suggestion
- Tool
- Transcription
- Web Preview
Hooks
Resources
Artifact
A titled panel for a generated file or document.
fibonacci.ts
TypeScript · 18 lines
export function fib(n: number): number {
return n < 2 ? n : fib(n - 1) + fib(n - 2);
}import { CopyIcon } from "lucide-react";
import {
Artifact,
ArtifactAction,
ArtifactActions,
ArtifactClose,
ArtifactCode,
ArtifactContent,
ArtifactDescription,
ArtifactHeader,
ArtifactTitle,
} from "@/registry/default/shared/artifact";
export default function Particle() {
return (
<Artifact className="w-full max-w-lg">
<ArtifactHeader>
<div>
<ArtifactTitle>fibonacci.ts</ArtifactTitle>
<ArtifactDescription>TypeScript · 18 lines</ArtifactDescription>
</div>
<ArtifactActions>
{/* Icon as a child element, not the `icon` prop.
*
* `ArtifactAction` is a Client Component (`artifact.tsx` is
* `"use client"`), and this particle renders inside MDX as a Server
* Component. `icon={CopyIcon}` hands a bare component *reference*
* across that boundary as a data prop, which RSC serialization
* rejects — React only knows how to serialize already-rendered
* elements across the boundary, not component functions. Rendering
* `<CopyIcon />` here produces an element, which serializes fine. */}
<ArtifactAction tooltip="Copy to clipboard">
<CopyIcon aria-hidden="true" />
</ArtifactAction>
<ArtifactClose />
</ArtifactActions>
</ArtifactHeader>
<ArtifactContent className="p-0">
<ArtifactCode
code={`export function fib(n: number): number {
return n < 2 ? n : fib(n - 1) + fib(n - 2);
}`}
/>
</ArtifactContent>
</Artifact>
);
}
Installation
pnpm dlx shadcn@latest add @frontal-labs/artifact
Usage
import {
Artifact,
ArtifactHeader,
ArtifactClose,
ArtifactTitle,
ArtifactDescription,
ArtifactActions,
ArtifactAction,
ArtifactContent,
} from "@/components/artifact";API Reference
| Export | Props |
|---|---|
Artifact | <div> attributes |
ArtifactHeader | <div> attributes |
ArtifactClose | Button props |
ArtifactTitle | <p> attributes |
ArtifactDescription | <p> attributes |
ArtifactActions | <div> attributes |
ArtifactAction | Button props, plus its own options |
ArtifactContent | <div> attributes |
Open the source under Manual above for the exact prop types.
On This Page