Skip to content
Back to search

ai-elements

AI Elements is a component library and custom registry built on top of shadcn/ui to help you build AI-native applications faster.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/vercel--ai-elements/badge.svg)](/listings/vercel--ai-elements)

HTML

<a href="/listings/vercel--ai-elements"><img src="/api/listings/vercel--ai-elements/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

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

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 153 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. # ▲ AI Elements
  2. > [!WARNING]
  3. > **AI Elements is moving to shadcn/ui.** This project will be deprecated at the end of November 2026 and replaced by [AI Elements from shadcn/ui](https://ui.shadcn.com/docs/ai-elements). New projects should use the shadcn/ui version once it's available.
  4. [AI Elements](https://elements.ai-sdk.dev) is a component library built on top of [shadcn/ui](https://ui.shadcn.com/) to help you build AI-native applications faster.
  5. ## Overview
  6. 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.
  7. ## Installation
  8. You can use the AI Elements CLI directly with npx, or install it globally:
  9. ```bash
  10. # Use directly (recommended)
  11. npx ai-elements@latest
  12. # Or using shadcn cli
  13. npx shadcn@latest add https://elements.ai-sdk.dev/api/registry/all.json
  14. ```
  15. ## Prerequisites
  16. Before using AI Elements, ensure your project meets these requirements:
  17. - **Node.js** 18 or later
  18. - **Next.js** project with [AI SDK](https://ai-sdk.dev/) installed
  19. - **shadcn/ui** initialized in your project (`npx shadcn@latest init`)
  20. - **Tailwind CSS** configured (AI Elements supports CSS Variables mode only)
  21. ## Usage
  22. ### Install All Components
  23. Install all available AI Elements components at once:
  24. ```bash
  25. npx ai-elements@latest
  26. ```
  27. This command will:
  28. - Set up shadcn/ui if not already configured
  29. - Install all AI Elements components to your configured components directory
  30. - Add necessary dependencies to your project
  31. ### Install Specific Components
  32. Install individual components using the `add` command:
  33. ```bash
  34. npx ai-elements@latest add <component-name>
  35. ```
  36. Examples:
  37. ```bash
  38. # Install the message component
  39. npx ai-elements@latest add message
  40. # Install the conversation component
  41. npx ai-elements@latest add conversation
  42. # Install the code-block component
  43. npx ai-elements@latest add code-block
  44. ```
  45. ### Alternative: Use with shadcn CLI
  46. You can also install components using the standard shadcn/ui CLI:
  47. ```bash
  48. # Install all components
  49. npx shadcn@latest add https://elements.ai-sdk.dev/api/registry/all.json
  50. # Install a specific component
  51. npx shadcn@latest add https://elements.ai-sdk.dev/api/registry/message.json
  52. ```
  53. ## Quick Start Example
  54. After installing components, you can use them in your React application:
  55. ```tsx
  56. "use client";
  57. import { useChat } from "@ai-sdk/react";
  58. import {
  59. Conversation,
  60. ConversationContent,
  61. } from "@/components/ai-elements/conversation";
  62. import {
  63. Message,
  64. MessageContent,
  65. MessageResponse,
  66. } from "@/components/ai-elements/message";
  67. export default function Chat() {
  68. const { messages } = useChat();
  69. return (
  70. <Conversation>
  71. <ConversationContent>
  72. {messages.map((message, index) => (
  73. <Message key={index} from={message.role}>
  74. <MessageContent>
  75. <MessageResponse>{message.content}</MessageResponse>
  76. </MessageContent>
  77. </Message>
  78. ))}
  79. </ConversationContent>
  80. </Conversation>
  81. );
  82. }
  83. ```
  84. ## How It Works
  85. The AI Elements CLI:
  86. 1. **Detects your package manager** (npm, pnpm, yarn, or bun) automatically
  87. 2. **Fetches component registry** from `https://elements.ai-sdk.dev/api/registry/registry.json`
  88. 3. **Installs components** using the shadcn/ui CLI under the hood
  89. 4. **Adds dependencies** and integrates with your existing shadcn/ui setup
  90. Components are installed to your configured shadcn/ui components directory (typically `@/components/ai-elements/`) and become part of your codebase, allowing for full customization.
  91. ## Configuration
  92. AI Elements uses your existing shadcn/ui configuration. Components will be installed to the directory specified in your `components.json` file.
  93. ## Recommended Setup
  94. For the best experience, we recommend:
  95. 1. **AI Gateway**: Set up [Vercel AI Gateway](https://vercel.com/docs/ai-gateway) and add `AI_GATEWAY_API_KEY` to your `.env.local`
  96. 2. **CSS Variables**: Use shadcn/ui's CSS Variables mode for theming
  97. 3. **TypeScript**: Enable TypeScript for better development experience
  98. ## Contributing
  99. If you'd like to contribute to AI Elements, please follow these steps:
  100. 1. Fork the repository
  101. 2. Create a new branch
  102. 3. Make your changes to the components in `packages/elements`.
  103. 4. Open a PR to the `main` branch.
  104. ---
  105. Made with ❤️ by [Vercel](https://vercel.com)

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.