AI Elements is a component library and custom registry built on top of shadcn/ui to help you build AI-native applications faster.
npx skills add https://github.com/vercel/ai-elements --skill ai-elementsقم بتثبيت هذه المهارة باستخدام واجهة سطر الأوامر (CLI) وابدأ في استخدام سير عمل SKILL.md في مساحة عملك.
AI Elements is a component library built on top of shadcn/ui to help you build AI-native applications faster.
AI Elements provides pre-built, customizable React 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 Next.js project.
You can use the AI Elements CLI directly with npx, or install it globally:
# Use directly (recommended)
npx ai-elements@latest
# Or using shadcn cli
npx shadcn@latest add https://elements.ai-sdk.dev/api/registry/all.json
Before using AI Elements, ensure your project meets these requirements:
npx shadcn@latest init)Install all available AI Elements components at once:
npx ai-elements@latest
This command will:
Install individual components using the add command:
npx ai-elements@latest add <component-name>
Examples:
# Install the message component
npx ai-elements@latest add message
# Install the conversation component
npx ai-elements@latest add conversation
# Install the code-block component
npx ai-elements@latest add code-block
You can also install components using the standard shadcn/ui CLI:
# Install all components
npx shadcn@latest add https://elements.ai-sdk.dev/api/registry/all.json
# Install a specific component
npx shadcn@latest add https://elements.ai-sdk.dev/api/registry/message.json
After installing components, you can use them in your React application:
"use client";
import { useChat } from "@ai-sdk/react";
import {
Conversation,
ConversationContent,
} from "@/components/ai-elements/conversation";
import {
Message,
MessageContent,
MessageResponse,
} from "@/components/ai-elements/message";
export default function Chat() {
const { messages } = useChat();
return (
<Conversation>
<ConversationContent>
{messages.map((message, index) => (
<Message key={index} from={message.role}>
<MessageContent>
<MessageResponse>{message.content}</MessageResponse>
</MessageContent>
</Message>
))}
</ConversationContent>
</Conversation>
);
}
The AI Elements CLI:
https://elements.ai-sdk.dev/api/registry/registry.jsonComponents are installed to your configured shadcn/ui components directory (typically @/components/ai-elements/) and become part of your codebase, allowing for full customization.
AI Elements uses your existing shadcn/ui configuration. Components will be installed to the directory specified in your components.json file.
For the best experience, we recommend:
AI_GATEWAY_API_KEY to your .env.localIf you'd like to contribute to AI Elements, please follow these steps:
packages/elements.main branch.Made with ❤️ by Vercel