View fulldotdev/ui on GitHub

Bubble

Displays conversational content in a message bubble. Supports variants, alignment, grouping, reactions, and collapsible content.

Installation

npx shadcn@latest add @fulldev/bubble

Usage

import { Bubble, BubbleContent, BubbleReactions } from "@/components/ui/bubble"
<Bubble>
  <BubbleContent>
    I checked the registry output and removed the stale route.
  </BubbleContent>
  <BubbleReactions>
    <span>👍</span>
  </BubbleReactions>
</Bubble>

Composition

Use the following composition to build a bubble:

Bubble
├── BubbleContent
└── BubbleReactions
BubbleGroup
├── Bubble
│   └── BubbleContent
└── Bubble
    └── BubbleContent

Variants

Use variant to change the visual treatment of the bubble.

VariantDescription
defaultA strong primary bubble, usually for the current user.
secondaryThe standard neutral bubble for conversation content.
mutedA lower-emphasis bubble for quiet supporting content.
tintedA subtle primary-tinted bubble.
outlineA bordered bubble for secondary or rich content.
ghostUnframed content for assistant text or rich content.
destructiveA destructive bubble for error or failed actions.

Alignment

Use align on Bubble to align the bubble to the start or end of the conversation.

alignDescription
startAlign the bubble to the start of the conversation.
endAlign the bubble to the end of the conversation.

Note: When building chat interfaces, you probably want to use alignment on the Message component itself, not the Bubble component. You can use the role prop on the Message component to automatically align the bubble to the start or end of the conversation.

Bubble Group

Use BubbleGroup to group consecutive bubbles from the same sender.

BubbleGroup
├── Bubble
│   └── BubbleContent
└── Bubble
    └── BubbleContent

You can turn a bubble into a link or button by using the render prop on BubbleContent.

import { Bubble, BubbleContent } from "@/components/ui/bubble"

export function BubbleLinkDemo() {
  return (
    <Bubble variant="muted">
      <BubbleContent render={<button />}>Click here</BubbleContent>
    </Bubble>
  )
}

Reactions

Use BubbleReactions for bubble reactions.

Show More / Collapsible

Long bubble content can be composed with Collapsible to allow for a show more or show less interaction.

Tooltip

Wrap a bubble in a Tooltip to reveal metadata on hover, such as when a message was read.

Popover

Pair a bubble with a Popover to surface more information on demand, such as the full error message for a failed action.

Accessibility

Bubble renders the presentational message surface.

Labeling Reactions

Reactions render as a row of emoji.

<BubbleReactions role="img" aria-label="Reactions: thumbs up, fire, and 8 more">
  <span>👍</span>
  <span>🔥</span>
  <span>+8</span>
</BubbleReactions>
<BubbleReactions>
  <Button aria-label="Thumbs up" variant="secondary" size="icon-xs">
    <ThumbsUpIcon />
  </Button>
</BubbleReactions>

Interactive Bubbles

When a bubble is clickable, render it as a real <button> or <a> with the render prop so it is focusable and exposes the correct role.

<Bubble variant="muted" align="end">
  <BubbleContent render={<button type="button" onClick={onReply} />}>
    I forgot my password
  </BubbleContent>
</Bubble>

Meaning Beyond Color

Bubble variants signal role and tone with color.

API Reference

Source: react/src/components/ui/bubble.tsx

Bubble

The root bubble wrapper.

PropTypeDefaultDescription
variant"default" | "secondary" | "muted" | "tinted" | "outline" | "ghost" | "destructive""default"The bubble visual treatment.
align"start" | "end""start"The inline alignment of the bubble.
classNamestring-Additional classes to apply to the root element.

BubbleContent

The bubble content wrapper.

PropTypeDefaultDescription
renderReactElement | function-Render the content as a different element such as a link.
classNamestring-Additional classes to apply to the content element.

BubbleReactions

Displays overlapped reactions for a bubble.

PropTypeDefaultDescription
side"top" | "bottom""bottom"The side of the bubble to anchor the reactions.
align"start" | "end""end"The inline alignment of the reactions.
classNamestring-Additional classes to apply to the reaction row.

BubbleGroup

Groups consecutive bubbles from the same sender.

PropTypeDefaultDescription
classNamestring-Additional classes to apply to the group root.