Bubble
Displays conversational content in a message bubble. Supports variants, alignment, grouping, reactions, and collapsible content.
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
Copy the following code into your app directory.
Command
Command
Manual
Manual
uv
Anatomy
Use the following composition to build a Bubble component.
Features
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 render for link and button bubbles
Customizable styling through the class_name prop on every part
Examples
Variants
Use variant to change the visual treatment of the bubble.
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.root to align the bubble to the start or 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.root component to automatically align the bubble to the start or end of the conversation.
Bubble Group
Use bubble.group to group consecutive bubbles from the same sender. Note the align prop should be set on the bubble.root component itself, not the bubble.group component.
composition
Links and Buttons
You can turn a bubble into a link or button by using the passing the interactive elements directly into the bubble.content slot. The bubble.content accepts *children so simply placing a button or link will render that component.
Reactions
Use bubble.reactions 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.
Show More / Collapsible
Long bubble content can be composed with Collapsible to allow for a show more or show less interaction. Use the collapsible.trigger component to trigger the collapsible content.
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.root 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.
python
When reactions are interactive, render buttons instead and give icon-only buttons an aria_label.
python
Interactive Bubbles
When a bubble is clickable, render it as a real <button> or <a>. bubble.-* content accept *children so simply passing in the interactive component will get rendered. bubble.content ships a visible focus ring for interactive elements, and the accessible name comes from the bubble text. No extra label is needed.
python
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.root
The root bubble wrapper.
bubble.content
The bubble content wrapper.
bubble.reactions
Displays overlapped reactions for a bubble.
bubble.group
Groups consecutive bubbles from the same sender.