Thanks to visit codestin.com
Credit goes to socket.dev

Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

ai-elements

Package Overview
Dependencies
Maintainers
5
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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.

latest
Codestin Search Appnpm
Version
1.1.2
Version published
Weekly downloads
5K
16.73%
Maintainers
5
Weekly downloads
 
Created
Source

▲ AI Elements

A command-line interface for installing AI Elements components - a component library built on top of shadcn/ui to help you build AI-native applications faster.

Overview

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.

Installation

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://registry.ai-sdk.dev/registry.json

Prerequisites

Before using AI Elements, ensure your project meets these requirements:

  • Node.js 18 or later
  • Next.js project with AI SDK installed
  • shadcn/ui initialized in your project (npx shadcn@latest init)
  • Tailwind CSS configured (AI Elements supports CSS Variables mode only)

Usage

Install All Components

Install all available AI Elements components at once:

npx ai-elements@latest

This command will:

  • Set up shadcn/ui if not already configured
  • Install all AI Elements components to your configured components directory
  • Add necessary dependencies to your project

Install Specific Components

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

Alternative: Use with shadcn CLI

You can also install components using the standard shadcn/ui CLI:

# Install all components
npx shadcn@latest add https://registry.ai-sdk.dev/registry.json

# Install a specific component
npx shadcn@latest add https://registry.ai-sdk.dev/message.json

Available Components

AI Elements includes the following components:

ComponentDescription
actionsInteractive action buttons for AI responses
branchBranch visualization for conversation flows
code-blockSyntax-highlighted code display with copy functionality
conversationContainer for chat conversations
imageAI-generated image display component
inline-citationInline source citations
loaderLoading states for AI operations
messageIndividual chat messages with avatars
prompt-formControlled form wrapper for prompt submission
prompt-inputAdvanced input component with model selection
prompt-input-attachmentsOpt-in file/image attachments for prompt input
reasoningDisplay AI reasoning and thought processes
responseFormatted AI response display
sourceSource attribution component
suggestionQuick action suggestions
taskTask completion tracking
toolTool usage visualization
web-previewEmbedded web page previews

Quick Start Example

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,
} from '@/components/ai-elements/message';
import { Response } from '@/components/ai-elements/response';

export default function Chat() {
  const { messages } = useChat();

  return (
    <Conversation>
      <ConversationContent>
        {messages.map((message, index) => (
          <Message key={index} from={message.role}>
            <MessageContent>
              <Response>{message.content}</Response>
            </MessageContent>
          </Message>
        ))}
      </ConversationContent>
    </Conversation>
  );
}

How It Works

The AI Elements CLI:

  • Detects your package manager (npm, pnpm, yarn, or bun) automatically
  • Fetches component registry from https://registry.ai-sdk.dev/registry.json
  • Installs components using the shadcn/ui CLI under the hood
  • Adds dependencies and integrates with your existing shadcn/ui setup

Components are installed to your configured shadcn/ui components directory (typically @/components/ai-elements/) and become part of your codebase, allowing for full customization.

Configuration

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: Set up Vercel AI Gateway and add AI_GATEWAY_API_KEY to your .env.local
  • CSS Variables: Use shadcn/ui's CSS Variables mode for theming
  • TypeScript: Enable TypeScript for better development experience

Made with ❤️ by Vercel

FAQs

Package last updated on 09 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts