
Ai Elements
Scaffold new AI chat UI pieces for the ai-elements registry so your Next.js app matches shadcn/ui and Vercel AI SDK patterns without guessing folder structure.
Install
npx skills add https://github.com/vercel-labs/vercel-skills --skill ai-elementsWhat is this skill?
- Guides adding components under packages/elements/src with ai-elements + shadcn/ui conventions
- Assumes Next.js, AI SDK, and shadcn/ui (install commands can bootstrap shadcn if missing)
- Covers conversations, messages, and related AI-native UI patterns from the npm ai-elements package
- Recommends Vercel AI Gateway and AI_GATEWAY_API_KEY for production API routing
- Supports dedicated ai-elements CLI or standard shadcn/ui registry workflow
Adoption & trust: 48 installs on skills.sh; 2/3 security scanners passed (skills.sh audits).
Recommended Skills
Frontend Designanthropics/skills
Vercel React Best Practicesvercel-labs/agent-skills
Remotion Best Practicesremotion-dev/skills
Vercel Composition Patternsvercel-labs/agent-skills
Develop Userscriptsxixu-me/skills
Next Best Practicesvercel-labs/next-skills
Journey fit
Common Questions / FAQ
Is Ai Elements safe to install?
skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Ai Elements
# AI Elements [AI Elements](https://www.npmjs.com/package/ai-elements) is a component library and custom registry built on top of [shadcn/ui](https://ui.shadcn.com/) to help you build AI-native applications faster. It provides pre-built components like conversations, messages and more. Installing AI Elements is straightforward and can be done in a couple of ways. You can use the dedicated CLI command for the fastest setup, or integrate via the standard shadcn/ui CLI if you've already adopted shadcn's workflow. ## Quick Start Here are some basic examples of what you can achieve using components from AI Elements. ## Prerequisites Before installing AI Elements, make sure your environment meets the following requirements: - [Node.js](https://nodejs.org/en/download/), version 18 or later - A [Next.js](https://nextjs.org/) project with the [AI SDK](https://ai-sdk.dev/) installed. - [shadcn/ui](https://ui.shadcn.com/) installed in your project. If you don't have it installed, running any install command will automatically install it for you. - We also highly recommend using the [AI Gateway](https://vercel.com/docs/ai-gateway) and adding `AI_GATEWAY_API_KEY` to your `env.local` so you don't have to use an API key from every provider. AI Gateway also gives $5 in usage per month so you can experiment with models. You can obtain an API key [here](https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys&title=Get%20your%20AI%20Gateway%20key). ## Installing Components You can install AI Elements components using either the AI Elements CLI or the shadcn/ui CLI. Both achieve the same result: adding the selected component’s code and any needed dependencies to your project. The CLI will download the component’s code and integrate it into your project’s directory (usually under your components folder). By default, AI Elements components are added to the `@/components/ai-elements/` directory (or whatever folder you’ve configured in your shadcn components settings). After running the command, you should see a confirmation in your terminal that the files were added. You can then proceed to use the component in your code. ## Usage Once an AI Elements component is installed, you can import it and use it in your application like any other React component. The components are added as part of your codebase (not hidden in a library), so the usage feels very natural. ## Example After installing AI Elements components, you can use them in your application like any other React component. For example: ```tsx title="conversation.tsx" "use client"; import { Message, MessageContent, MessageResponse, } from "@/components/ai-elements/message"; import { useChat } from "@ai-sdk/react"; const Example = () => { const { messages } = useChat(); return ( <> {messages.map(({ role, parts }, index) => ( <Message from={role} key={index}> <MessageContent> {parts.map((part, i) => { switch (part.type) { case "text": return ( <MessageResponse key={`${role}-${i}`}> {part.text} </MessageResponse> ); } })} </MessageContent> </Message> ))} </> ); }; export default Example; ``` In the example above, we import the `Message` component from our AI Elements directory and include it in our JSX. Then, we compose the component with the `MessageContent` and `MessageResponse` subcomponents. You can style or configure the component just as you would if you wrote it yourself – since the code lives in your project, y