页面简介
A component library and custom registry built on top of shadcn/ui to help you build AI-native applications faster.
正文摘录
AI Elements is moving to shadcn/ui. This project will be deprecated at the end of November 2026. Learn moreOverviewIntroductionBenefitsCommunityThe Vercel AI Frontend StackUsageSetupUsageSkillTroubleshootingContributingHow to ContributeNew ComponentsPhilosophyChatbotAttachmentsChain of ThoughtCheckpointConfirmationContextConversationInline CitationMessageModel SelectorPlanPrompt InputQuestionQueueReasoningShimmerSourcesSuggestionTaskToolCodeAgentArtifactCode BlockCommitEnvironment VariablesFile TreeJSX PreviewPackage InfoSandboxSchema DisplaySnippetStack TraceTerminalTest ResultsWeb PreviewVoiceAudio PlayerMic SelectorPersonaSpeech InputTranscriptionVoice SelectorWorkflowCanvasConnectionControlsEdgeNodePanelToolbarUtilitiesImageOpen In ChatChatbotIDEWorkflowAI ElementsA component library and custom registry built on top of shadcn/ui to help you build AI-native applications faster.Explore Components$Fully ComposableEvery component is a building block. Combine small, focused pieces to create exactly the UI you need.AI SDK IntegrationDeep integration with the AI SDK. Streaming, status states and type safety built-in.shadcn/ui FoundationBuilt on shadcn/ui conventions. Your existing theme and setup apply automatically.Components to build anythingMix and match components to build chat experiences, workflows, IDEs, voice agents and more.7 QueuedHow do I set up the project?What is the roadmap for Q4?Update the default logo to this png.Please generate a changelog.Add dark mode support.Optimize database queries.Set up CI/CD pipeline.5 TodoWrite project documentationComplete the README and API docsImplement authenticationFix bug #42Resolve crash on settings pageRefactor queue logicUnify queue and todo state managementAdd unit testsIncrease test coverage for hooksRewrite AI Elements to SolidJSRewrite the AI Elements component library from React to SolidJS while maintaining compatibility with existing React-based shadcn/ui components using solid-js/compat, updating all 29 components and their test suite.Toggle planBuild ⌘↩Research Assistantopenai/gpt-5.2-proInstructionsYou are a helpful research assistant. Your job is to search the web for information and summarize findings for the user. Always cite your sources and provide accurate, up-to-date information.ToolsSearch the web for informationRead and parse a URLSummarize text into key pointsOutput Schemaz.object({ sentiment: z.enum(['positive', 'negative', 'neutral']), score: z.number(), summary: z.string(),})Chain of ThoughtSearching for profiles for Hayden Bleaselwww.x.comwww.instagram.comwww.github.comFound the profile photo for Hayden BleaselHayden Bleasel's profile photo from x.com, showing a Ghibli-style man.Hayden Bleasel is an Australian product designer, software engineer, and founder. He is currently based in the United States working for Vercel, an American cloud application company.Searching for recent work...www.github.comwww.dribbble.comFound project filesSearching "app/page.tsx, components structure"Readpage.tsxScanning 52 filesScanning 2 filesReading fileslayout.tsxdatabase_queryPendingParameters{}database_queryAwaiting Approvaldatabase_queryRespondeddatabase_queryRunningdatabase_queryCompleteddatabase_queryErrordatabase_queryDeniedgreet.tsfunction greet(name: string): string { return `Hello, ${name}!`;} console.log(greet("World"));Environment VariablesDATABASE_URLRequired••••••••••••••••••••API_KEYRequired•••••••••••••••••••NODE_ENV••••••••••PORT••••Fast, Flexible InstallationInstall only what you need. The CLI adds components directly to your codebase with full source code access. No hidden dependencies, tree-shaking friendly.$npx ai-elements@latest add conversation✔ Checking registry.✔ Installing dependencies.✔ Created 1 file:- components/ai-elements/conversation.tsxℹ Skipped 1 files: (files might be identical, use --overwrite to overwrite)- components/ui/button.tsxGet started quicklySee AI Elements in action with one of our examples.ChatbotA full-featured chat interface with streaming, markdown and file attachments."use client"; import { Conversation, ConversationContent, ConversationScrollButton,} from "@repo/elements/conversation";import { Message, MessageBranch, MessageBranchContent, MessageBranchNext, MessageBranchPage, MessageBranchPrevious, MessageBranchSelector, MessageContent, MessageResponse,} from "@repo/elements/message";import type { PromptInputMessage } from "@repo/elements/prompt-input";import { PromptInput, PromptInputButton, PromptInputFooter, PromptInputTextarea, PromptInputTools,} from "@repo/elements/prompt-input";import { Reasoning, ReasoningContent, ReasoningTrigger,} from "@repo/elements/reasoning";import { Source, Sources, SourcesContent, SourcesTrigger,} from "@repo/elements/sources";import { Suggestion, Suggestions } from "@repo/elements/suggestion";import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger,} from "@repo/shadcn-ui/components/ui/dropdown-menu";import { cn } from "@repo/shadcn-ui/lib/utils";import type { ToolUIPart } from "ai";import { AudioWaveformIcon, BarChartIcon, BoxIcon, CameraIcon, CodeSquareIcon, FileIcon, GlobeIcon, GraduationCapIcon, ImageIcon, NotepadTextIcon, PaperclipIcon, ScreenShareIcon,} from "lucide-react";import { nanoid } from "nanoid";import { memo, useCallback, useEffect, useState } from "react";import { toast } from "sonner"; interface MessageType { key: string; from: "user" | "assistant"; sources?: { href: string; title: string }[]; versions: { id: string; content: string; }[]; reasoning?: { content: string; duration: number; }; tools?: { name: string; description: string; status: ToolUIPart["state"]; parameters: Record<string, unknown>; result: string | undefined; error: string | undefined; }[]; isReasoningComplete?: boolean; isContentComplete?: boolean; isReasoningStreaming?: boolean;} const mockMessages: MessageType[] = [ { from: "user", key: nanoid(), versions: [ { content: "Can you explain how to use React hooks effectively?", id: nanoid(), }, ], }, { from: "assistant", key: nanoid(), sources: [ { href: "https://react.dev/reference/react", title: "React Documentation", }, { href: "https://react.dev/reference/react-dom", title: "React DOM Documentation", }, ], tools: [ { description: "Searching React documentation", error: undefined, name: "mcp", parameters: { query: "React hooks best practices", source: "react.dev", }, result: `{ "query": "React hooks best practices", "results": [ { "title": "Rules of Hooks", "url": "https://react.dev/warnings/invalid-hook-call-warning", "snippet": "Hooks must be called at the top level of your React function components or custom hooks. Don't call hooks inside loops, conditions, or nested functions." }, { "title": "useState Hook", "url": "https://react.dev/reference/react/useState", "snippet": "useState is a React Hook that lets you add state to your function components. It returns an array with two values: the current state and a function to update it." }, { "title": "useEffect Hook", "url": "https://react.dev/reference/react/useEffect", "snippet": "useEffect lets you synchronize a component with external systems. It runs after render and can be used to perform side effects like data fetching." } ]}`, status: "input-available", }, ], versions: [ { content: `# React Hooks Best Practices React hooks are a powerful feature that let you use state and other React features without writing classes. Here are some tips for using them effectively: ## Rules of Hooks 1. **Only call hooks at the top level** of your component or custom hooks2. **Don't call hooks inside loops, conditions, or nested functions** ## Common Hooks - **useState**: For local component state- **useEffect**: For side effects like data fetching- **useContext**: For consuming context- **useReducer**: For complex state logic- **useCallback**: For memoizing functions- **useMemo**: For memoizing values ## Example of useState and useEffect \`\`\`jsxfunction ProfilePage({ userId }) { const [user, setUser] = useState(null); useEffect(() => { // This runs after render and when userId changes fetchUser(userId).then(userData => { setUser(userData); }); }, [userId]); return user ? <Profile user={user} /> : <Loading />;}\`\`\` Would you like me to explain any specific hook in more detail?`, id: nanoid(), }, ], }, { from: "user", key: nanoid(), versions: [ { content: "Yes, could you explain useCallback and useMemo in more detail? When should I use one over the other?", id: nanoid(), }, { content: "I'm particularly interested in understanding the performance implications of useCallback and useMemo. Could you break down when each is most appropriate?", id: nanoid(), }, { content: "Thanks for the overview! Could you dive deeper into the specific use cases where useCallback and useMemo make the biggest difference in React applications?", id: nanoid(), }, ], }, { from: "assistant", key: nanoid(), reasoning: { content: `The user is asking for a detailed explanation of useCallback and useMemo. I should provide a clear and concise explanation of each hook's purpose and how they differ. The useCallback hook is used to memoize functions to prevent unnecessary re-renders of child components that receive functions as props. The useMemo hook is used to memoize values to avoid expensive recalculations on every render. Both hooks help with performance optimization, but they serve different purposes.`, duration: 10, }, versions: [ { content: `## useCallback vs useMemo Both hooks help with *performance optimization*, but they serve different purposes: ### useCallback \`useCallback\` memoizes **functions** to prevent unnecessary re-renders of child components that receive functions as props. \`\`\`jsx// Without useCallback - a new function is created on every renderconst handleClick = () => { console.log(count);}; // With useCallback - the function is only recreated when dependencies changeconst handleClick = useCallback(() => { console.log(count);}, [count]);\`\`\` ### useMemo \`useMemo\` memoizes **