hadcn chat

ChatBubble

The ChatBubble component chat-bubble.svelte 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?
US

Examples

  • Default layout with actions and altered styles
  • US
    Hello!
    AI
    Hover me!
    AI
  • Default layout without actions and without altered styles
  • 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.
childrenSnippetnullThe children of the chat bubble.
classstringnullAdditional classes to apply to the chat bubble.

ChatBubbleMessage

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

ChatBubbleAvatar

You can also just use the Avatar component from shadcn-svelte instead

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

ChatBubbleAction

PropTypeDefaultDescription
iconSnippetnullThe icon of the action.
onclick() => voidnullThe onclick event of the action.
classstringnullAdditional classes to apply to the action.