Documentation

Bubble

Chat-style message bubbles with seven variants, start or end alignment, grouping, reactions and clickable suggestions.

Preview

Hey! Can VitNode do chat bubbles now?
It sure can.
Seven variants, both sides of the conversation, and reactions that hang off the edge like a sticky note.
Okay, I am impressed. What else?
Could not load the joke of the day. The joke was too good to send.

Usage

import {
  Bubble,
  BubbleContent,
  BubbleGroup,
  BubbleReactions,
} from '@vitnode/core/components/ui/bubble'
<Bubble>
  <BubbleContent>I removed the stale route. You are welcome.</BubbleContent>
</Bubble>

A bubble shrinks to fit its text and never grows past 80% of the row. New bubbles grow in from their tail corner; with reduced motion they only fade.

Variants

  • Sent by you, loud and proud.
    default
  • The standard neutral reply.
    secondary
  • A quieter aside.
    muted
  • Soft, from your primary color.
    tinted
  • Great for suggestions.
    outline
  • Unframed and full width, like an assistant answer.
    ghost
  • Upload failed. Try again.
    destructive

default is usually the current user, secondary the standard reply. ghost drops the frame and takes the full width.

Alignment

Your messages go on the end side, everyone else's on the start.

<Bubble align="end">
  <BubbleContent>Sent by me.</BubbleContent>
</Bubble>

Grouping

BubbleGroup tightens the spacing between consecutive bubbles from one sender. Set align on each Bubble, not on the group.

<BubbleGroup>
  <Bubble variant="muted">
    <BubbleContent>First thought.</BubbleContent>
  </Bubble>
  <Bubble variant="muted">
    <BubbleContent>Second thought, arriving fashionably late.</BubbleContent>
  </Bubble>
</BubbleGroup>

Reactions

  • Tests passed on the first try.
    side="bottom" align="end"
  • Shipping it on Friday.
    side="bottom" align="start"
  • Who renamed the main branch?
    side="top" align="end"

BubbleReactions pins a pill to the bubble's edge. It overlaps the bubble, so leave extra gap between rows.

<BubbleReactions aria-label="Reactions: rocket, eyes" role="img" side="top">
  <span>🚀</span>
  <span>👀</span>
</BubbleReactions>

Use render on BubbleContent to make a bubble a real link or button, like a quick-reply suggestion.

<Bubble variant="outline">
  <BubbleContent render={<button onClick={onPick} type="button" />}>
    Show me the plugin docs
  </BubbleContent>
</Bubble>

Use with Message

For an avatar, sender name or read receipt, wrap bubbles in a Message. Bubbles inside follow the message's align.

Accessibility

  • Bubble is only the visual surface. Put role="log" and an aria-label on the conversation container.
  • Give BubbleReactions role="img" and an aria-label, so screen readers announce it once instead of reading every emoji. Interactive reactions should be labelled buttons.
  • Clickable bubbles must be a real <button> or <a> via render.
  • Variants signal tone with color, so keep the meaning in the text too.

Props

Bubble

Prop

Type

BubbleContent

Prop

Type

BubbleReactions

Prop

Type

API Reference

Base UI - useRender