|
1 | 1 | # AI Elements Vue |
2 | 2 |
|
3 | | -[AI Elements Vue](https://ai-elements-vue.com) is a component library built on top of [shadcn-vue](https://www.shadcn-vue.com/) to help you build AI-native applications faster. |
| 3 | +[AI Elements Vue](https://ai-elements-vue.com) is an unofficial community-led [Vue](https://vuejs.org) port of [AI Elements](https://github.com/vercel/ai-elements). |
| 4 | + |
| 5 | +> **Note** <br> **We are not affiliated with AI Elements, but we have received support for this project** <br> This is a project born out of the need for a similar project for the Vue ecosystem. |
| 6 | +
|
| 7 | +## Overview |
| 8 | + |
| 9 | +[AI Elements Vue](https://ai-elements-vue.com) is a component library built on top of [shadcn-vue](https://www.shadcn-vue.com/) to help you build AI-native applications faster. It provides pre-built, customizable Vue components specifically designed for AI applications, including conversations, messages, code blocks, reasoning displays, and more. The CLI makes it easy to add these components to your Vue.js or Nuxt.js project. |
| 10 | + |
| 11 | +## Installation |
| 12 | + |
| 13 | +You can use the AI Elements Vue CLI directly with npx, or install it globally: |
| 14 | + |
| 15 | +```bash |
| 16 | +# Use directly (recommended) |
| 17 | +npx ai-elements-vue@latest |
| 18 | + |
| 19 | +# Or using shadcn-vue cli |
| 20 | +npx shadcn-vue@latest add https://registry.ai-elements-vue.com/all.json |
| 21 | +``` |
| 22 | + |
| 23 | +## Prerequisites |
| 24 | + |
| 25 | +Before using AI Elements Vue, ensure your project meets these requirements: |
| 26 | + |
| 27 | +- **Node.js** 18 or later |
| 28 | +- **Vue.js, Nuxt.js** project with [AI SDK](https://ai-sdk.dev/) installed |
| 29 | +- **shadcn-vue** initialized in your project (`npx shadcn-vue@latest init`) |
| 30 | +- **Tailwind CSS** configured (AI Elements Vue supports CSS Variables mode only) |
| 31 | + |
| 32 | +## Usage |
| 33 | + |
| 34 | +### Install All Components |
| 35 | + |
| 36 | +Install all available AI Elements Vue components at once: |
| 37 | + |
| 38 | +```bash |
| 39 | +npx ai-elements-vue@latest |
| 40 | +``` |
| 41 | + |
| 42 | +This command will: |
| 43 | +- Set up shadcn-vue if not already configured |
| 44 | +- Install all AI Elements Vue components to your configured components directory |
| 45 | +- Add necessary dependencies to your project |
| 46 | + |
| 47 | +### Install Specific Components |
| 48 | + |
| 49 | +Install individual components using the `add` command: |
| 50 | + |
| 51 | +```bash |
| 52 | +npx ai-elements-vue@latest add <component-name> |
| 53 | +``` |
| 54 | + |
| 55 | +Examples: |
| 56 | +```bash |
| 57 | +# Install the message component |
| 58 | +npx ai-elements-vue@latest add message |
| 59 | + |
| 60 | +# Install the conversation component |
| 61 | +npx ai-elements-vue@latest add conversation |
| 62 | + |
| 63 | +# Install the code-block component |
| 64 | +npx ai-elements-vue@latest add code-block |
| 65 | +``` |
| 66 | + |
| 67 | +### Alternative: Use with shadcn-vue CLI |
| 68 | + |
| 69 | +You can also install components using the standard shadcn-vue CLI: |
| 70 | + |
| 71 | +```bash |
| 72 | +# Install all components |
| 73 | +npx shadcn-vue@latest add https://registry.ai-elements-vue.com/all.json |
| 74 | + |
| 75 | +# Install a specific component |
| 76 | +npx shadcn-vue@latest add https://registry.ai-elements-vue.com/message.json |
| 77 | +``` |
| 78 | + |
| 79 | +## Available Components |
| 80 | + |
| 81 | +AI Elements Vue includes the following components: |
| 82 | + |
| 83 | +| Component | Status | Description | |
| 84 | +|-----------|--------|-------------| |
| 85 | +| `message` | ✅ 已完成 | Individual chat messages with avatars | |
| 86 | +| `conversation` | ✅ 已完成 | Container for chat conversations | |
| 87 | +| `response` | ✅ 已完成 | Formatted AI response display | |
| 88 | +| `prompt-input` | ✅ 已完成 | Advanced input component with model selection | |
| 89 | +| `actions` | ❌ 未完成 | Interactive action buttons for AI responses | |
| 90 | +| `branch` | ❌ 未完成 | Branch visualization for conversation flows | |
| 91 | +| `code-block` | ❌ 未完成 | Syntax-highlighted code display with copy functionality | |
| 92 | +| `image` | ❌ 未完成 | AI-generated image display component | |
| 93 | +| `inline-citation` | ❌ 未完成 | Inline source citations | |
| 94 | +| `loader` | ❌ 未完成 | Loading states for AI operations | |
| 95 | +| `reasoning` | ❌ 未完成 | Display AI reasoning and thought processes | |
| 96 | +| `source` | ❌ 未完成 | Source attribution component | |
| 97 | +| `suggestion` | ❌ 未完成 | Quick action suggestions | |
| 98 | +| `task` | ❌ 未完成 | Task completion tracking | |
| 99 | +| `tool` | ❌ 未完成 | Tool usage visualization | |
| 100 | + |
| 101 | +## How It Works |
| 102 | + |
| 103 | +The AI Elements CLI: |
| 104 | + |
| 105 | +1. **Detects your package manager** (npm, pnpm, yarn, or bun) automatically |
| 106 | +2. **Fetches component registry** from `https://registry.ai-elements-vue.com/all.json` |
| 107 | +3. **Installs components** using the shadcn-vue CLI under the hood |
| 108 | +4. **Adds dependencies** and integrates with your existing shadcn-vue setup |
| 109 | + |
| 110 | +Components are installed to your configured shadcn-vue components directory (typically `@/components/ai-elements/`) and become part of your codebase, allowing for full customization. |
| 111 | + |
| 112 | +## Configuration |
| 113 | + |
| 114 | +AI Elements Vue uses your existing shadcn-vue configuration. Components will be installed to the directory specified in your `components.json` file. |
| 115 | + |
| 116 | +## Recommended Setup |
| 117 | + |
| 118 | +For the best experience, we recommend: |
| 119 | + |
| 120 | +1. **AI Gateway**: Set up [Vercel AI Gateway](https://vercel.com/docs/ai-gateway) and add `AI_GATEWAY_API_KEY` to your `.env.local` |
| 121 | +2. **CSS Variables**: Use shadcn-vue's CSS Variables mode for theming |
| 122 | +3. **TypeScript**: Enable TypeScript for better development experience |
| 123 | + |
| 124 | +## Contributing |
| 125 | + |
| 126 | +If you'd like to contribute to AI Elements Vue, please follow these steps: |
| 127 | + |
| 128 | +1. Fork the repository |
| 129 | +2. Create a new branch |
| 130 | +3. Make your changes to the components in `packages/elements`. |
| 131 | +4. Open a PR to the `main` branch. |
| 132 | + |
| 133 | +--- |
| 134 | + |
| 135 | +Made with ❤️ by [cwandev](https://github.com/cwandev) |
0 commit comments