Artifact

The Artifact component provides a structured container for displaying generated content like code, documents, or other outputs with built-in header actions.

Dijkstra's Algorithm Implementation

Updated 1 minute ago

Installation

pnpm dlx shadcn-svelte@latest add https://svelte-ai-elements.vercel.app/r/artifact.json

If you prefer using jsrepo, please install via the command below:

pnpm dlx jsrepo add @ai/elements/ai-elements/artifact

Usage

Props

Artifact

PropTypeDefaultDescription
childrenSnippet-Child components to render
classstring-Additional CSS classes to apply to the container
...restPropsHTMLAttributes<HTMLDivElement>-All other div props are supported

ArtifactHeader

PropTypeDefaultDescription
childrenSnippet-Child components to render (typically title, description, and actions)
classstring-Additional CSS classes to apply to the header
...restPropsHTMLAttributes<HTMLDivElement>-All other div props are supported

ArtifactTitle

PropTypeDefaultDescription
childrenSnippet-Title text content
classstring-Additional CSS classes to apply to the title
...restPropsHTMLAttributes<HTMLParagraphElement>-All other paragraph props are supported

ArtifactDescription

PropTypeDefaultDescription
childrenSnippet-Description text content
classstring-Additional CSS classes to apply to the description
...restPropsHTMLAttributes<HTMLParagraphElement>-All other paragraph props are supported

ArtifactActions

PropTypeDefaultDescription
childrenSnippet-Child ArtifactAction components to render
classstring-Additional CSS classes to apply to the actions container
...restPropsHTMLAttributes<HTMLDivElement>-All other div props are supported

ArtifactAction

PropTypeDefaultDescription
tooltipstring-Tooltip text to display on hover
labelstring-Accessible label for screen readers (falls back to tooltip if not provided)
icontypeof Icon-Lucide icon component to render
childrenSnippet-Custom content to render (used if icon is not provided)
classstring-Additional CSS classes to apply to the button
variant'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link''ghost'Visual style variant of the button
size'default' | 'sm' | 'lg' | 'icon''sm'Size of the button
...restPropsHTMLButtonAttributes | HTMLAnchorAttributes-All other button/anchor props are supported

ArtifactClose

PropTypeDefaultDescription
childrenSnippet-Custom close icon (defaults to X icon if not provided)
classstring-Additional CSS classes to apply to the button
variant'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link''ghost'Visual style variant of the button
size'default' | 'sm' | 'lg' | 'icon''sm'Size of the button
...restPropsHTMLButtonAttributes | HTMLAnchorAttributes-All other button/anchor props are supported

ArtifactContent

PropTypeDefaultDescription
childrenSnippet-Content to render inside the artifact
classstring-Additional CSS classes to apply to the content container
...restPropsHTMLAttributes<HTMLDivElement>-All other div props are supported