Chat Bubble

ChatBubble

The ChatBubble component chat-bubble.tsx is the main component in this library. It is used to display a chat bubble along with its message, avatar and other content.

Wrap the ChatBubble component with ChatMessageList to properly show the chat bubbles.

US
Hello, how has your day been? I hope you are doing well.
AI
Hi, I am doing well, thank you for asking. How can I help you today?
AI

Installation

npx shadcn-chat-cli@latest add chat-bubble

Examples

Default layout w/ actions and altered styles

US
Hover me!
AI
Hover me too!
AI

AI layout w/ actions

US
Help me with my essay.
AI
I can help you with that. What do you need help with?

API Reference

ChatBubble

PropTypeDefaultDescription
variant'sent' | 'received''received'The variant of the chat bubble. Used to display the correct position of the chat bubble and the correct colors.
layout'default' | 'ai''default'The layout of the chat bubble. Used to display various layouts.
childrenReact.ReactNodenullThe children of the chat bubble.
classNamestringnullAdditional classes to apply to the chat bubble.

ChatBubbleMessage

PropTypeDefaultDescription
isLoadingbooleanfalseIf the message is loading. Shows loading component MessageLoading if true.
classNamestringnullAdditional classes to apply to the message.

ChatBubbleAvatar

You can also just use the Avatar component from shadcn/ui instead

PropTypeDefaultDescription
srcstringnullThe source of the avatar.
fallbackstringnullThe fallback of the avatar.
classNamestringnullAdditional classes to apply to the avatar.

ChatBubbleAction

PropTypeDefaultDescription
iconReact.ReactNodenullThe icon of the action.
onClick() => voidnullThe onClick event of the action.
classNamestringnullAdditional classes to apply to the action.