Command Palette

Search for a command to run...

AI Chat

Main chat container with header, body, and footer sections for building AI chat interfaces

Open in v0Open in
Ready
Messages go here
Input controls go here

Overview

A flexible chat layout component with AiChatHeader, AiChatBody, and AiChatFooter slots. Provides a context for managing chat status across child components.

Installation

bunx shadcn@latest add @elements/chat

Usage

import {
  AiChat,
  AiChatHeader,
  AiChatBody,
  AiChatFooter,
} from "@/components/elements/ai-elements/chat/ai-chat";

export function ChatInterface() {
  return (
    <AiChat status="ready">
      <AiChatHeader>
        <h1>Chat Assistant</h1>
      </AiChatHeader>
      <AiChatBody>
        {/* Messages component goes here */}
      </AiChatBody>
      <AiChatFooter>
        {/* Input component goes here */}
      </AiChatFooter>
    </AiChat>
  );
}

Props

AiChat

PropTypeDefaultDescription
status"ready" | "submitted" | "streaming" | "error""ready"Current chat status
childrenReactNode-Child components
classNamestring-Additional CSS classes

AiChatHeader

PropTypeDefaultDescription
childrenReactNode-Header content
classNamestring-Additional CSS classes

AiChatBody

PropTypeDefaultDescription
childrenReactNode-Body content (usually messages)
classNamestring-Additional CSS classes

AiChatFooter

PropTypeDefaultDescription
childrenReactNode-Footer content (usually input)
classNamestring-Additional CSS classes

Context Hook

Access the chat status from any child component:

import { useChatContext } from "@/components/elements/ai-elements/chat/ai-chat";

function StatusIndicator() {
  const { status } = useChatContext();
  return <span>Status: {status}</span>;
}

Features

  • Full-height chat layout with flex column
  • Header with border separator
  • Scrollable body section
  • Footer with border separator
  • Status context for streaming states
  • Composable slot-based architecture