āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā š shadcn/directory/ai-elements/artifact ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
A container component for displaying generated content like code, documents, or other outputs with built-in actions.
The Artifact component provides a structured container for displaying generated content like code, documents, or other outputs with built-in header actions.
npx ai-elements@latest add artifact
import {
Artifact,
ArtifactAction,
ArtifactActions,
ArtifactContent,
ArtifactDescription,
ArtifactHeader,
ArtifactTitle,
} from '@/components/ai-elements/artifact';
<Artifact>
<ArtifactHeader>
<div>
<ArtifactTitle>Dijkstra's Algorithm Implementation</ArtifactTitle>
<ArtifactDescription>Updated 1 minute ago</ArtifactDescription>
</div>
<ArtifactActions>
<ArtifactAction icon={CopyIcon} label="Copy" tooltip="Copy to clipboard" />
</ArtifactActions>
</ArtifactHeader>
<ArtifactContent>
Your content here
</ArtifactContent>
</Artifact>
# Dijkstra's Algorithm Implementation
import heapq
def dijkstra(graph, start):
distances = {node: float('inf') for node in graph}
distances[start] = 0
heap = [(0, start)]
visited = set()
while heap:
current_distance, current_node = heapq.heappop(heap)
if current_node in visited:
continue
visited.add(current_node)
for neighbor, weight in graph[current_node].items():
distance = current_distance + weight
if distance < distances[neighbor]:
distances[neighbor] = distance
heapq.heappush(heap, (distance, neighbor))
return distances
# Example graph
graph = {
# Graph definition...
}
| Prop | Type | | ...props? | React.HTMLAttributes<HTMLDivElement> |
| Prop | Type | | ...props? | React.HTMLAttributes<HTMLDivElement> |
| Prop | Type | | ...props? | React.HTMLAttributes<HTMLParagraphElement> |
| Prop | Type | | ...props? | React.HTMLAttributes<HTMLParagraphElement> |
| Prop | Type | | ...props? | React.HTMLAttributes<HTMLDivElement> |
| Prop | Type | | tooltip? | string | | label? | string | | icon? | LucideIcon | | ...props? | React.ComponentProps<typeof Button> |
| Prop | Type | | ...props? | React.ComponentProps<typeof Button> |
| Prop | Type | | ...props? | React.HTMLAttributes<HTMLDivElement> |
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā