Bubble
Chat message bubbles with variants, grouped corners, reactions and room for interactive content.
- Chat UI components
- 4 parts
- 13 examples
- vs shadcn/ui
@base-ui/reactclass-variance-authority
See it in a real product: Chat Thread, Model Compare, Streaming, and 1 more
View blockpnpm dlx shadcn@latest add https://hextaui.com/r/bubble.jsonAdds the component, the HextaUI theme tokens and any HextaUI components it depends on.
Add the theme tokens to your global CSS, if you haven’t yet.
Install the dependencies.
pnpm add @base-ui/react class-variance-authority cnCopy and paste the following code into your project.
components/ui/bubble.tsx Update the import paths to match your project setup.
Seven treatments, from a strong primary bubble to unframed ghost content for assistant replies. destructive tints the surface and colors icons inside it.
align="end" pushes a bubble to the end of the row for the current user’s messages. It follows the reading direction.
Wrap consecutive messages from one sender in <BubbleGroup />. Corners on the sender side tighten so the run reads as one block, and a lone bubble stays fully round.
Set shape on a group to style all of its bubbles, or on a single bubble. joined is the default.
shape="tail" draws a tail on the last bubble of a run, matching the bubble color. Outline and ghost bubbles skip it.
<BubbleReactions /> overlaps the bubble edge and reserves its own space, so the next row needs no extra gap. Give a static row role="img" and a label, or use buttons for interactive reactions.
Render a <Collapsible /> as the bubble content to fold long messages. The bubble grows smoothly and the hidden text stays searchable.
Render a bubble as a tooltip trigger to show details like the read time. Add tabIndex so keyboard users can reach it.
Render the content as a <button> to make the whole bubble a popover trigger, for example to explain a failed delivery.
Unbroken strings, URLs, emoji and CJK text wrap inside the bubble instead of overflowing a narrow column.
A quoted bubble inside another keeps radii concentric with its parent.
Alignment, joined corners, tails and reactions all mirror in right-to-left layouts.
- Bubbles are plain containers. Wrap a conversation in a list or a
role="log"region if new messages should be announced. - Emoji-only reaction rows need
role="img"and anaria-labelthat spells out the reactions. - Interactive content rendered as a button or link gets a focus ring that follows the bubble’s corners.
Every part renders a <div> by default and accepts its attributes, plus a render prop to swap the element.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "secondary" | "muted" | "tinted" | "outline" | "ghost" | "destructive" | "default" |
align | "start" | "end" | "start" |
shapeInherited from BubbleGroup when not set. | "uniform" | "joined" | "tail" | "joined" |
render | ReactElement | (props, state) => ReactElement | <div> |
| Attribute | Description |
|---|---|
data-slot="bubble" | Target bubbles in CSS. |
data-variant | The current variant. |
data-align | The current alignment. |
data-shape | The resolved shape. |
--bubble-bg | The surface color, also used by the tail. |
--bubble-fg | The text color. |
--bubble-border | The ring color. |
--bubble-radius | The corner radius. |
--bubble-radius-joined | The tighter radius used between grouped bubbles. |
--bubble-accent | Icon color inside the content. Set by destructive. |
| Prop | Type | Default |
|---|---|---|
renderRender a <button> or <a> to make it interactive. | ReactElement | (props, state) => ReactElement | <div> |
| Attribute | Description |
|---|---|
data-slot="bubble-content" | Target the bubble surface in CSS. |
| Prop | Type | Default |
|---|---|---|
shapeApplies to every bubble inside the group. | "uniform" | "joined" | "tail" | – |
render | ReactElement | (props, state) => ReactElement | <div> |
| Attribute | Description |
|---|---|
data-slot="bubble-group" | Target groups in CSS. |
data-shape | The group shape, when set. |
| Prop | Type | Default |
|---|---|---|
side | "top" | "bottom" | "bottom" |
align | "start" | "end" | "end" |
render | ReactElement | (props, state) => ReactElement | <div> |
| Attribute | Description |
|---|---|
data-slot="bubble-reactions" | Target reaction rows in CSS. |
data-side | The current side. |
data-align | The current alignment. |
- AttachmentFile and image cards for uploads, with progress, states, actions, a full-card trigger and names that keep their extension.
- MarkerQuiet notes between content, like date dividers and system events, with sticky dates and times that read as Today or Yesterday.
- MessageA chat message row with an avatar, name, bubbles and status, where new messages rise in from the sender's side.
- Message scrollerA chat scroll area that follows new messages, keeps your place while you read back, and counts what you missed on the jump button.
Used in Pro blocks
Blocks that build on Bubble.
Every block comes with HextaUI Pro, and Prompt Input is free.