diff --git a/apps/www/content/2.components/artifact.md b/apps/www/content/2.components/artifact.md new file mode 100644 index 0000000..13d505e --- /dev/null +++ b/apps/www/content/2.components/artifact.md @@ -0,0 +1,402 @@ +--- +title: Artifact +description: A container component for displaying generated content like code, documents, or other outputs with built-in actions. +icon: lucide:file-text +--- + +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 + +:::tabs{variant="card"} + ::div{label="ai-elements-vue"} + ```sh + npx ai-elements-vue@latest add artifact + ``` + :: + ::div{label="shadcn-vue"} + + ```sh + npx shadcn-vue@latest add https://registry.ai-elements-vue.com/artifact.json + ``` + :: +::: + +## Install Manually + +Copy and paste the following code in the same folder. + +:::code-group + ```vue [Artifact.vue] + + + + ``` + + ```vue [ArtifactAction.vue] + + + + ``` + + ```vue [ArtifactActions.vue] + + + + ``` + + ```vue [ArtifactClose.vue] + + + + ``` + + ```vue [ArtifactContent.vue] + + + + ``` + + ```vue [ArtifactDescription.vue] + + + + ``` + + ```vue [ArtifactHeader.vue] + + + + ``` + + ```vue [ArtifactTitle.vue] + + + + ``` + + ```ts [index.ts] + export { default as Artifact } from './Artifact.vue' + export { default as ArtifactAction } from './ArtifactAction.vue' + export { default as ArtifactActions } from './ArtifactActions.vue' + export { default as ArtifactClose } from './ArtifactClose.vue' + export { default as ArtifactContent } from './ArtifactContent.vue' + export { default as ArtifactDescription } from './ArtifactDescription.vue' + export { default as ArtifactHeader } from './ArtifactHeader.vue' + export { default as ArtifactTitle } from './ArtifactTitle.vue' + ``` + +::: + +## 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 + +:::ComponentLoader{label="Artifact" componentName="Artifact"} +::: + +## Props + +### `` + +:::field-group + ::field{name="[...props]" type="HTMLAttributes"} + Additional props forwarded to the root `
` element. + :: +::: + +### `` + +:::field-group + ::field{name="[...props]" type="HTMLAttributes"} + Additional props forwarded to the header `
` element. + :: +::: + +### `` + +:::field-group + ::field{name="[...props]" type="HTMLAttributes"} + Additional props forwarded to the title `

` element. + :: +::: + +### `` + +:::field-group + ::field{name="[...props]" type="HTMLAttributes"} + Additional props forwarded to the description `

` element. + :: +::: + +### `` + +:::field-group + ::field{name="[...props]" type="HTMLAttributes"} + Additional props forwarded to the actions `

` element. + :: +::: + +### `` + +:::field-group + ::field{name="tooltip" type="string"} + Tooltip text shown when hovering the action button. + :: + + ::field{name="label" type="string"} + Screen reader label used for accessible button text. + :: + + ::field{name="icon" type="LucideIcon"} + Lucide icon component rendered inside the action button. + :: + + ::field{name="[...props]" type="ButtonProps"} + Additional props forwarded to the underlying shadcn-vue `Button`. + :: +::: + +### `` + +:::field-group + ::field{name="[...props]" type="ButtonProps"} + Additional props forwarded to the underlying shadcn-vue `Button`. + :: +::: + +### `` + +:::field-group + ::field{name="[...props]" type="HTMLAttributes"} + Additional props forwarded to the content `
` element. + :: +::: diff --git a/apps/www/plugins/ai-elements.ts b/apps/www/plugins/ai-elements.ts index afe782c..82f4990 100644 --- a/apps/www/plugins/ai-elements.ts +++ b/apps/www/plugins/ai-elements.ts @@ -1,6 +1,7 @@ import { Actions, ActionsHover, + Artifact, Branch, ChainOfThought, CodeBlock, @@ -39,6 +40,7 @@ export default defineNuxtPlugin((nuxtApp) => { vueApp.component('ComponentLoader', ComponentLoader) vueApp.component('ComponentViewer', ComponentViewer) + vueApp.component('Artifact', Artifact) vueApp.component('Actions', Actions) vueApp.component('ActionsHover', ActionsHover) vueApp.component('Branch', Branch) diff --git a/packages/elements/src/artifact/Artifact.vue b/packages/elements/src/artifact/Artifact.vue new file mode 100644 index 0000000..6375401 --- /dev/null +++ b/packages/elements/src/artifact/Artifact.vue @@ -0,0 +1,24 @@ + + + diff --git a/packages/elements/src/artifact/ArtifactAction.vue b/packages/elements/src/artifact/ArtifactAction.vue new file mode 100644 index 0000000..a5ce01e --- /dev/null +++ b/packages/elements/src/artifact/ArtifactAction.vue @@ -0,0 +1,71 @@ + + + diff --git a/packages/elements/src/artifact/ArtifactActions.vue b/packages/elements/src/artifact/ArtifactActions.vue new file mode 100644 index 0000000..693b617 --- /dev/null +++ b/packages/elements/src/artifact/ArtifactActions.vue @@ -0,0 +1,20 @@ + + + diff --git a/packages/elements/src/artifact/ArtifactClose.vue b/packages/elements/src/artifact/ArtifactClose.vue new file mode 100644 index 0000000..53f6d2a --- /dev/null +++ b/packages/elements/src/artifact/ArtifactClose.vue @@ -0,0 +1,38 @@ + + + diff --git a/packages/elements/src/artifact/ArtifactContent.vue b/packages/elements/src/artifact/ArtifactContent.vue new file mode 100644 index 0000000..9003798 --- /dev/null +++ b/packages/elements/src/artifact/ArtifactContent.vue @@ -0,0 +1,21 @@ + + + diff --git a/packages/elements/src/artifact/ArtifactDescription.vue b/packages/elements/src/artifact/ArtifactDescription.vue new file mode 100644 index 0000000..9efded6 --- /dev/null +++ b/packages/elements/src/artifact/ArtifactDescription.vue @@ -0,0 +1,21 @@ + + + diff --git a/packages/elements/src/artifact/ArtifactHeader.vue b/packages/elements/src/artifact/ArtifactHeader.vue new file mode 100644 index 0000000..e669d8a --- /dev/null +++ b/packages/elements/src/artifact/ArtifactHeader.vue @@ -0,0 +1,24 @@ + + + diff --git a/packages/elements/src/artifact/ArtifactTitle.vue b/packages/elements/src/artifact/ArtifactTitle.vue new file mode 100644 index 0000000..7cecf4d --- /dev/null +++ b/packages/elements/src/artifact/ArtifactTitle.vue @@ -0,0 +1,21 @@ + + + diff --git a/packages/elements/src/artifact/index.ts b/packages/elements/src/artifact/index.ts new file mode 100644 index 0000000..c921739 --- /dev/null +++ b/packages/elements/src/artifact/index.ts @@ -0,0 +1,8 @@ +export { default as Artifact } from './Artifact.vue' +export { default as ArtifactAction } from './ArtifactAction.vue' +export { default as ArtifactActions } from './ArtifactActions.vue' +export { default as ArtifactClose } from './ArtifactClose.vue' +export { default as ArtifactContent } from './ArtifactContent.vue' +export { default as ArtifactDescription } from './ArtifactDescription.vue' +export { default as ArtifactHeader } from './ArtifactHeader.vue' +export { default as ArtifactTitle } from './ArtifactTitle.vue' diff --git a/packages/elements/src/index.ts b/packages/elements/src/index.ts index 2e9e507..f5d4f34 100644 --- a/packages/elements/src/index.ts +++ b/packages/elements/src/index.ts @@ -1,4 +1,5 @@ export * from './actions' +export * from './artifact' export * from './branch' export * from './chain-of-thought' export * from './code-block' diff --git a/packages/examples/src/artifact.vue b/packages/examples/src/artifact.vue new file mode 100644 index 0000000..f5899da --- /dev/null +++ b/packages/examples/src/artifact.vue @@ -0,0 +1,124 @@ + + + diff --git a/packages/examples/src/index.ts b/packages/examples/src/index.ts index fd38924..104d2a7 100644 --- a/packages/examples/src/index.ts +++ b/packages/examples/src/index.ts @@ -1,5 +1,6 @@ export { default as ActionsHover } from './actions-hover.vue' export { default as Actions } from './actions.vue' +export { default as Artifact } from './artifact.vue' export { default as Branch } from './branch.vue' export { default as ChainOfThought } from './chain-of-thought.vue' export { default as CodeBlockDark } from './code-block-dark.vue'