Conversation

PreviousNext

A scrolling conversation container with auto-scroll and sticky-to-bottom behavior for chat interfaces.

Installation

pnpm dlx @elevenlabs/agents-cli@latest components add conversation

Usage

import {
  Conversation,
  ConversationContent,
  ConversationEmptyState,
  ConversationScrollButton,
} from "@/components/ui/conversation"

Basic Conversation

<Conversation>
  <ConversationContent>
    {messages.map((message) => (
      <div key={message.id}>{message.content}</div>
    ))}
  </ConversationContent>
  <ConversationScrollButton />
</Conversation>

With Empty State

<Conversation>
  <ConversationContent>
    {messages.length === 0 ? (
      <ConversationEmptyState
        title="No messages yet"
        description="Start a conversation to see messages here"
      />
    ) : (
      messages.map((message) => <div key={message.id}>{message.content}</div>)
    )}
  </ConversationContent>
  <ConversationScrollButton />
</Conversation>

API Reference

Conversation

The main container component that manages scrolling behavior and sticky-to-bottom functionality.

Props

Extends all props from StickToBottom component from use-stick-to-bottom.

PropTypeDescription
classNamestringOptional CSS classes
initial"smooth"Initial scroll behavior (default: "smooth")
resize"smooth"Resize scroll behavior (default: "smooth")
...propsStickToBottomAll standard StickToBottom component props

ConversationContent

Container for conversation messages.

Props

PropTypeDescription
classNamestringOptional CSS classes
...propsStickToBottom.ContentAll StickToBottom.Content props

ConversationEmptyState

Displays when there are no messages in the conversation.

Props

PropTypeDescription
titlestringTitle text (default: "No messages yet")
descriptionstringDescription text
iconReactNodeOptional icon to display
classNamestringOptional CSS classes
childrenReactNodeCustom content (overrides default rendering)
...propsHTMLDivElementAll standard div element props

ConversationScrollButton

A scroll-to-bottom button that appears when the user scrolls up.

Props

PropTypeDescription
classNamestringOptional CSS classes
...propsButtonPropsAll standard Button props

Notes

  • Built on top of use-stick-to-bottom for smooth scrolling behavior
  • Automatically scrolls to bottom when new messages are added
  • Scroll button only appears when user has scrolled away from the bottom
  • Supports smooth scrolling animations
  • Works with any message component structure
  • This component is inspired by Vercel's AI SDK Conversation component with modifications for ElevenLabs UI