Skip to content

Chat

Chat message bubbles for displaying conversations with avatars and metadata.

import { Chat } from 'asterui'

Basic Chat

Simple chat bubbles with different positions.

Hey! How are you?
I'm doing great, thanks for asking!
import { Chat } from 'asterui'

function App() {
  return (
      <div>
        <Chat position="start" message="Hey! How are you?" />
        <Chat position="end" message="I'm doing great, thanks for asking!" />
      </div>
    )
}

export default App

With Avatars

Chat bubbles with user avatars.

User
Hey! Did you see the new updates?
Me
Yes! They look amazing!
import { Chat } from 'asterui'

function App() {
  return (
      <div>
        <Chat
          position="start"
          avatar="/avatar-1.webp"
          avatarAlt="User"
          message="Hey! Did you see the new updates?"
        />
        <Chat
          position="end"
          avatar="/avatar-2.webp"
          avatarAlt="Me"
          message="Yes! They look amazing!"
        />
      </div>
    )
}

export default App

With Headers

Chat bubbles with name and timestamp headers.

Alice
Good morning! Ready for the meeting?
Bob
Yes, joining now!
import { Chat } from 'asterui'

function App() {
  return (
      <div>
        <Chat
          position="start"
          avatar="/avatar-1.webp"
          header={<span>Alice <time className="text-xs opacity-50">12:45</time></span>}
          message="Good morning! Ready for the meeting?"
        />
        <Chat
          position="end"
          avatar="/avatar-2.webp"
          header={<span>Bob <time className="text-xs opacity-50">12:46</time></span>}
          message="Yes, joining now!"
        />
      </div>
    )
}

export default App

Colored Bubbles

Chat bubbles with different color variants.

Primary color message
Secondary color message
Success color message
Error color message
import { Chat } from 'asterui'

function App() {
  return (
      <div>
        <Chat position="start" color="primary" message="Primary color message" />
        <Chat position="end" color="secondary" message="Secondary color message" />
        <Chat position="start" color="success" message="Success color message" />
        <Chat position="end" color="error" message="Error color message" />
      </div>
    )
}

export default App

With Footer

Chat bubbles with delivery status footer.

Did you get my message?
Hello?
import { Chat } from 'asterui'

function App() {
  return (
      <div>
        <Chat
          position="end"
          avatar="/avatar-1.webp"
          footer={<span className="text-xs opacity-50">Delivered</span>}
          message="Did you get my message?"
        />
        <Chat
          position="end"
          avatar="/avatar-2.webp"
          footer={<span className="text-xs opacity-50">Seen at 12:46</span>}
          message="Hello?"
        />
      </div>
    )
}

export default App
PropertyDescriptionTypeDefault
messageMessage contentReact.ReactNode-
positionBubble position'start' | 'end''start'
avatarAvatar image URLstring-
avatarAltAvatar alt textstring-
headerHeader content (name, time)React.ReactNode-
footerFooter content (status)React.ReactNode-
colorBubble color variant'primary' | 'secondary' | 'accent' | 'neutral' | 'info' | 'success' | 'warning' | 'error'-
classNameAdditional CSS classesstring-
data-testidTest ID for testingstring-
  • Use meaningful alt text for avatar images
  • Message content is readable by screen readers
  • Position classes help convey conversation flow