labsUI

Message Bubble

User/assistant chat bubbles with avatar slot, streaming dots and copyable code blocks.

npx @kznlabs/labsui add message-bubble

Assistant

Online
  1. You

    How do I animate height with motion?

  2. Assistant

    Animate to auto with a spring. motion measures the target height for you:

    tsx
    <motion.div  animate={{ height: open ? "auto" : 0 }}  transition={{ type: "spring", stiffness: 400, damping: 30 }}/>

Simulated streaming reply

<MessageBubble>

Chat bubble. Children are rich content: <p>, inline <code>, lists, <Code>.

  • from*
    "user" | "assistant"

    Side and surface: "user" on the right in the accent, "assistant" on the left.

  • avatar
    ReactNode

    Avatar slot, e.g. <Avatar size="sm" />.

  • children
    ReactNode

    Message content: text, code, attachments.

  • name
    string

    Sender shown above the bubble.

  • streaming
    boolean

    Shows animated typing dots after the content.

  • time
    string

    Time shown next to the name, e.g. "12:04".

PropTypeDefault
from*

Side and surface: "user" on the right in the accent, "assistant" on the left.

"user" | "assistant"—
avatar

Avatar slot, e.g. <Avatar size="sm" />.

ReactNode—
children

Message content: text, code, attachments.

ReactNode—
name

Sender shown above the bubble.

string—
streaming

Shows animated typing dots after the content.

boolean—
time

Time shown next to the name, e.g. "12:04".

string—

* required. Every component also takes className.