Bubble
Displays conversational content in a message bubble. Supports variants, alignment, grouping, reactions, and collapsible content.
import {
Bubble,
BubbleContent,
BubbleGroup,
BubbleReactions,
} from '@/components/ui/bubble';
<template>
<div class="flex w-full max-w-sm flex-col gap-8 py-12">
<Bubble @align="end">
<BubbleContent>Hey there! what's up?</BubbleContent>
</Bubble>
<BubbleGroup>
<Bubble @variant="muted">
<BubbleContent>Hey! Want to see chat bubbles?</BubbleContent>
</Bubble>
<Bubble @variant="muted">
<BubbleContent>
I can group messages, switch sides, and keep the whole thread easy to
scan.
</BubbleContent>
<BubbleReactions aria-label="Reaction: thumbs up" role="img">
<span>👍</span>
</BubbleReactions>
</Bubble>
</BubbleGroup>
<Bubble @align="end">
<BubbleContent>Sure. Hit me with your best demo.</BubbleContent>
</Bubble>
<Bubble @variant="muted">
<BubbleContent>
Yes. You are reading a demo that is demoing itself. Very meta. Very
on-brand.
</BubbleContent>
<BubbleReactions
aria-label="Reactions: thumbs up, fire, eyes, and 2 more"
role="img"
>
<span>👍</span>
<span>🔥</span>
<span>👀</span>
<span>+2</span>
</BubbleReactions>
</Bubble>
</div>
</template>
The
Bubble
component displays framed conversational content. Use it for chat text, short structured output, quoted replies, suggestions, and reactions.
For full-featured chat interfaces, use the
Message
component.
Bubble
is intentionally scoped to the bubble surface. Place avatars, names, timestamps, metadata, and message-level actions in
Message
.
Installation
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
Use
BubbleGroup
to group consecutive bubbles from the same sender:
BubbleGroup
├── Bubble
│ └── BubbleContent
└── Bubble
└── BubbleContentFeatures
- Seven visual variants, from a strong primary bubble to unframed ghost content
- Start and end alignment for sender and receiver bubbles
- Reactions that anchor to the bubble edge with configurable side and alignment
- Bubbles size to their content, up to 80% of the container width
-
Polymorphic content via
@asChildfor link and button bubbles -
Customizable styling through the
@classargument on every part
Examples
Variants
Use
@variant
to change the visual treatment of the bubble.
import { Bubble, BubbleContent, BubbleReactions } from '@/components/ui/bubble';
<template>
<div class="flex w-full max-w-sm flex-col gap-12 py-12">
<Bubble>
<BubbleContent>This is the default primary bubble.</BubbleContent>
</Bubble>
<Bubble @align="end" @variant="secondary">
<BubbleContent>This is the secondary variant.</BubbleContent>
</Bubble>
<Bubble @variant="muted">
<BubbleContent>
This one is muted. It uses a lower emphasis color for the chat bubble.
</BubbleContent>
<BubbleReactions aria-label="Reaction: thumbs up" role="img">
<span>👍</span>
</BubbleReactions>
</Bubble>
<Bubble @align="end" @variant="tinted">
<BubbleContent>
This one is tinted. The tint is a softer color derived from the primary
color.
</BubbleContent>
</Bubble>
<Bubble @variant="outline">
<BubbleContent>We can also use an outlined variant.</BubbleContent>
</Bubble>
<Bubble @align="end" @variant="destructive">
<BubbleContent>Or a destructive variant with a reaction.</BubbleContent>
<BubbleReactions aria-label="Reaction: fire" role="img">
<span>🔥</span>
</BubbleReactions>
</Bubble>
<Bubble @variant="ghost">
<BubbleContent>
<div class="flex flex-col gap-4">
<p>
Ghost bubbles work for assistant text,
<strong>markdown</strong>, and other content that should not be
framed.
</p>
<p>
This is perfect for assistant messages that should not have a frame
and can take the full width of the container. You can also render
<code>code</code>
in it.
</p>
<p>
Ghost bubbles are full width and can take the full width of the
container.
</p>
</div>
</BubbleContent>
</Bubble>
</div>
</template>
A bubble sizes to its content, up to 80% of the container width. The
ghost
variant removes the max-width so assistant text and rich content can span the full row.
Alignment
Use
@align
on
Bubble
to align the bubble to the start or end of the conversation.
import { Bubble, BubbleContent } from '@/components/ui/bubble';
<template>
<div class="flex w-full max-w-sm flex-col gap-8 py-12">
<Bubble @variant="muted">
<BubbleContent>
This bubble is aligned to the start. This is the default alignment.
</BubbleContent>
</Bubble>
<Bubble @align="end">
<BubbleContent>
This bubble is aligned to the end. Use this for user messages.
</BubbleContent>
</Bubble>
</div>
</template>
When building chat interfaces, you probably want to use alignment on the
Message
component itself, not the
Bubble
component. You can use the
@role
argument 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. Note the
@align
argument should be set on the
Bubble
component itself, not the
BubbleGroup
component.
BubbleGroup
├── Bubble
│ └── BubbleContent
└── Bubble
└── BubbleContentimport {
Bubble,
BubbleContent,
BubbleGroup,
BubbleReactions,
} from '@/components/ui/bubble';
<template>
<div class="flex w-full max-w-sm flex-col gap-8 py-12">
<Bubble @variant="muted">
<BubbleContent>Can you tell me what's the issue?</BubbleContent>
</Bubble>
<BubbleGroup>
<Bubble @align="end">
<BubbleContent>You tell me!</BubbleContent>
</Bubble>
<Bubble @align="end">
<BubbleContent>It worked yesterday. You broke it!</BubbleContent>
</Bubble>
<Bubble @align="end">
<BubbleContent>Find the bug and fix it.</BubbleContent>
<BubbleReactions @align="start" aria-label="Reactions: eyes">
<span>👀</span>
</BubbleReactions>
</Bubble>
</BubbleGroup>
<Bubble @variant="muted">
<BubbleContent>
Want me to diff yesterday's you against today's you? It's a bit
embarrassing.
</BubbleContent>
</Bubble>
</div>
</template>Links and Buttons
You can turn a bubble into a link or button by using the
@asChild
argument on
BubbleContent
. Apply the yielded
classes
and the
data-slot="bubble-content"
attribute to your element.
import { on } from '@ember/modifier';
import { service } from '@ember/service';
import Component from '@glimmer/component';
import { Bubble, BubbleContent, BubbleGroup } from '@/components/ui/bubble';
import type ToastService from '@/services/toast';
export default class BubbleLinkButtonDemo extends Component {
@service declare toast: ToastService;
forgotPassword = () => {
this.toast.add({ message: 'You clicked forgot password' });
};
helpSubscription = () => {
this.toast.add({ message: 'You clicked help with subscription' });
};
somethingElse = () => {
this.toast.add({ message: 'You clicked something else. Talk to a human.' });
};
<template>
<div class="flex w-full max-w-sm flex-col gap-8 py-12">
<Bubble @variant="muted">
<BubbleContent>How can I help you today?</BubbleContent>
</Bubble>
<BubbleGroup>
<Bubble @align="end" @variant="tinted">
<BubbleContent @asChild={{true}} as |content|>
<button
class={{content.classes}}
data-slot="bubble-content"
type="button"
{{on "click" this.forgotPassword}}
>
I forgot my password
</button>
</BubbleContent>
</Bubble>
<Bubble @align="end" @variant="tinted">
<BubbleContent @asChild={{true}} as |content|>
<button
class={{content.classes}}
data-slot="bubble-content"
type="button"
{{on "click" this.helpSubscription}}
>
I need help with my subscription
</button>
</BubbleContent>
</Bubble>
<Bubble @align="end" @variant="tinted">
<BubbleContent @asChild={{true}} as |content|>
<button
class={{content.classes}}
data-slot="bubble-content"
type="button"
{{on "click" this.somethingElse}}
>
Something else. Talk to a human.
</button>
</BubbleContent>
</Bubble>
</BubbleGroup>
</div>
</template>
}import { Bubble, BubbleContent } from '@/components/ui/bubble';
<template>
<Bubble @variant="muted">
<BubbleContent @asChild={{true}} as |content|>
<button
type="button"
class={{content.classes}}
data-slot="bubble-content"
>
Click here
</button>
</BubbleContent>
</Bubble>
</template>Reactions
Use
BubbleReactions
for bubble reactions. You can use it to display reactions or quick action buttons. Use
@side
and
@align
to position the row —
@side="top"
anchors it to the upper edge. Reactions overlap the bubble edge, so leave vertical space between rows — the examples below use a larger gap for this reason.
import { on } from '@ember/modifier';
import { service } from '@ember/service';
import Component from '@glimmer/component';
import { Bubble, BubbleContent, BubbleReactions } from '@/components/ui/bubble';
import { Button } from '@/components/ui/button';
import type ToastService from '@/services/toast';
export default class BubbleReactionsDemo extends Component {
@service declare toast: ToastService;
runCommand = () => {
this.toast.success('You clicked yes, running command...');
};
<template>
<div class="flex w-full max-w-sm flex-col gap-12 py-12">
<Bubble @align="end" @variant="muted">
<BubbleContent>
I don't need tests, I know my code works.
</BubbleContent>
<BubbleReactions
@align="start"
aria-label="Reactions: thumbs up, surprised"
role="img"
>
<span>👍</span>
<span>😮</span>
</BubbleReactions>
</Bubble>
<Bubble @variant="muted">
<BubbleContent>
Bold. Fine I'll add some tests. I'll let you know when they're done.
</BubbleContent>
<BubbleReactions
aria-label="Reactions: eyes, rocket, and 2 more"
role="img"
>
<span>👀</span>
<span>🚀</span>
<span>+2</span>
</BubbleReactions>
</Bubble>
<Bubble @align="end" @variant="default">
<BubbleContent>
Tests passed on the first try. All 142 of them. Looking good!
</BubbleContent>
<BubbleReactions
@align="start"
@side="top"
aria-label="Reactions: party popper, clapping hands"
role="img"
>
<span>🎉</span>
<span>👏</span>
</BubbleReactions>
</Bubble>
<Bubble @variant="destructive">
<BubbleContent>Are you sure I can run this command?</BubbleContent>
<BubbleReactions>
<Button @size="sm" @variant="ghost" {{on "click" this.runCommand}}>
Yes, run it
</Button>
</BubbleReactions>
</Bubble>
</div>
</template>
}Show More / Collapsible
Long bubble content can be composed with
Collapsible
to allow for a show more or show less interaction. Use the
CollapsibleTrigger
component to trigger the collapsible content.
import { on } from '@ember/modifier';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { Bubble, BubbleContent } from '@/components/ui/bubble';
import { Button } from '@/components/ui/button';
import { Collapsible, CollapsibleTrigger } from '@/components/ui/collapsible';
import ChevronDown from '~icons/lucide/chevron-down';
const text = `The accessibility review found two focus states that were visually too subtle in dark mode.
I checked the dialog, menu, and drawer paths because each one renders focusable controls inside a layered surface.
The dialog and drawer are fine. The menu needs the hover and focus tokens split so keyboard focus stays visible when the pointer is not involved.
I also recommend keeping the change in the style file instead of the primitive so the other themes can choose their own focus treatment later.`;
const previewLength = 180;
export default class BubbleCollapsible extends Component {
@tracked open = false;
isLong = text.length > previewLength;
preview = `${text.slice(0, previewLength)}...`;
setOpen = (open: boolean) => {
this.open = open;
};
get displayText() {
return this.open || !this.isLong ? text : this.preview;
}
<template>
<div class="flex w-full max-w-sm flex-col gap-8 py-12">
<Bubble @variant="muted">
<BubbleContent>How can I help you today?</BubbleContent>
</Bubble>
<Bubble @align="end" @variant="muted">
<BubbleContent>
<Collapsible @onOpenChange={{this.setOpen}} @open={{this.open}}>
<div class="whitespace-pre-line">{{this.displayText}}</div>
{{#if this.isLong}}
<CollapsibleTrigger @asChild={{true}} as |trigger|>
<Button
@class="gap-1 p-0 text-muted-foreground"
@variant="link"
aria-controls={{trigger.aria-controls}}
aria-expanded={{trigger.aria-expanded}}
data-disabled={{trigger.data-disabled}}
data-slot={{trigger.data-slot}}
data-state={{trigger.data-state}}
disabled={{trigger.disabled}}
{{on "click" trigger.onClick}}
>
{{if this.open "Show less" "Show more"}}
<ChevronDown
class={{if this.open "rotate-180" ""}}
data-icon="inline-end"
/>
</Button>
</CollapsibleTrigger>
{{/if}}
</Collapsible>
</BubbleContent>
</Bubble>
</div>
</template>
}Tooltip
Wrap a bubble in a
Tooltip
to reveal metadata on hover, such as when a message was read.
import { Bubble, BubbleContent, BubbleReactions } from '@/components/ui/bubble';
import { Button } from '@/components/ui/button';
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from '@/components/ui/tooltip';
import Check from '~icons/lucide/check';
<template>
<div class="flex w-full max-w-sm flex-col gap-4 py-12">
<Bubble @variant="secondary">
<BubbleContent>Did you remove the stale route?</BubbleContent>
</Bubble>
<Bubble @align="end">
<BubbleContent>Yes, removed it from the registry.</BubbleContent>
<BubbleReactions @class="p-0">
<Tooltip>
<TooltipTrigger @asChild={{true}}>
<Button @class="rounded-full" @size="icon-sm" @variant="ghost">
<Check />
</Button>
</TooltipTrigger>
<TooltipContent>Read on Jan 5, 2026 at 4:32 PM</TooltipContent>
</Tooltip>
</BubbleReactions>
</Bubble>
</div>
</template>Popover
Pair a bubble with a
Popover
to surface more information on demand, such as the full error message for a failed action.
import { Bubble, BubbleContent, BubbleReactions } from '@/components/ui/bubble';
import { Button } from '@/components/ui/button';
import {
Popover,
PopoverContent,
PopoverTrigger,
} from '@/components/ui/popover';
import Info from '~icons/lucide/info';
<template>
<div class="flex w-full max-w-sm flex-col gap-4 py-12">
<Bubble @align="end">
<BubbleContent>Run the build script.</BubbleContent>
</Bubble>
<Bubble @variant="destructive">
<BubbleContent>Failed to run the command.</BubbleContent>
<BubbleReactions>
<Popover>
<PopoverTrigger @asChild={{true}} as |trigger|>
<Button
@class="rounded-full aria-expanded:text-destructive"
@size="icon-sm"
@variant="ghost"
aria-label="Show error details"
{{trigger.modifiers}}
>
<Info />
</Button>
</PopoverTrigger>
<PopoverContent>
<div class="flex flex-col gap-1.5">
<h4 class="text-sm font-medium leading-none">
Command failed with exit code 1
</h4>
<p class="text-sm text-muted-foreground">
ENOENT: no such file or directory, open pnpm-lock.yaml
</p>
</div>
</PopoverContent>
</Popover>
</BubbleReactions>
</Bubble>
</div>
</template>Accessibility
Bubble
renders the presentational message surface. Keep conversation-level semantics on the surrounding container and follow the guidelines below.
Labeling Reactions
Reactions render as a row of emoji. A screen reader reads each glyph with no context, and counters like
+8
are announced as "plus eight". Group the row as a single image with a descriptive
aria-label
so it announces once.
role="img"
also hides the individual emoji from assistive tech, so no
aria-hidden
is needed.
<BubbleReactions role="img" aria-label="Reactions: thumbs up, fire, and 8 more">
<span>👍</span>
<span>🔥</span>
<span>+8</span>
</BubbleReactions>
When reactions are interactive, render buttons instead and give icon-only buttons an
aria-label
.
<BubbleReactions>
<Button aria-label="Thumbs up" @variant="secondary" @size="icon-sm">
<ThumbsUp />
</Button>
</BubbleReactions>Interactive Bubbles
When a bubble is clickable, render it as a real
<button>
or
<a>
with the
@asChild
argument so it is focusable and exposes the correct role.
BubbleContent
ships a visible focus ring for interactive elements, and the accessible name comes from the bubble text. No extra label is needed.
<Bubble @variant="muted" @align="end">
<BubbleContent @asChild={{true}} as |content|>
<button
type="button"
class={{content.classes}}
data-slot="bubble-content"
{{on "click" this.onReply}}
>
I forgot my password
</button>
</BubbleContent>
</Bubble>Meaning Beyond Color
Bubble variants signal role and tone with color. Pair them with text, alignment, or icons so meaning is not conveyed by color alone. For a destructive bubble, keep the error context in the message text rather than relying on the color treatment.
API Reference
Bubble
The root bubble wrapper.
BubbleContent
The bubble content wrapper.
BubbleReactions
Displays overlapped reactions for a bubble.
BubbleGroup
Groups consecutive bubbles from the same sender.