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.

Install using CLI

AI Elements Vue
shadcn-vue CLI
npx ai-elements-vue@latest add artifact

Install Manually

Copy and paste the following code in the same folder.

Artifact.vue
ArtifactAction.vue
ArtifactActions.vue
ArtifactClose.vue
ArtifactContent.vue
ArtifactDescription.vue
ArtifactHeader.vue
ArtifactTitle.vue
index.ts
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@repo/shadcn-vue/lib/utils'
import { computed } from 'vue'

const props = defineProps<{
  class?: HTMLAttributes['class']
}>()

const classes = computed(() => cn(
  'flex flex-col overflow-hidden rounded-lg border bg-background shadow-sm',
  props.class,
))
</script>

<template>
  <div
    :class="classes"
    v-bind="$attrs"
  >
    <slot />
  </div>
</template>

Features

  • Structured container with header and content areas
  • Built-in header with title and description support
  • Flexible action buttons with tooltips
  • Customizable styling for all subcomponents
  • Support for close buttons and action groups
  • Clean, modern design with border and shadow
  • Responsive layout that adapts to content
  • TypeScript support with proper type definitions
  • Composable architecture for maximum flexibility

Examples

With Code Display

Props

<Artifact />

[...props]HTMLAttributes
Additional props forwarded to the root <div> element.

<ArtifactHeader />

[...props]HTMLAttributes
Additional props forwarded to the header <div> element.

<ArtifactTitle />

[...props]HTMLAttributes
Additional props forwarded to the title <p> element.

<ArtifactDescription />

[...props]HTMLAttributes
Additional props forwarded to the description <p> element.

<ArtifactActions />

[...props]HTMLAttributes
Additional props forwarded to the actions <div> element.

<ArtifactAction />

tooltipstring
Tooltip text shown when hovering the action button.
labelstring
Screen reader label used for accessible button text.
iconLucideIcon
Lucide icon component rendered inside the action button.
[...props]ButtonProps
Additional props forwarded to the underlying shadcn-vue Button.

<ArtifactClose />

[...props]ButtonProps
Additional props forwarded to the underlying shadcn-vue Button.

<ArtifactContent />

[...props]HTMLAttributes
Additional props forwarded to the content <div> element.