This page as markdown: /bubble.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

Bubble

Status: stable

The surface a message's content sits on: four treatments, an align-aware tail, a readable measure cap, and an optional row of reaction pills.

Keywords: chat bubble, message bubble, speech bubble, reactions, conversation, messaging, ai chat

Usage

The tinted (or untinted) surface a turn's content sits on. Kept separate from Message because the row's layout and the content's surface change independently — an assistant's markdown answer wants no surface at all in exactly the same row a one-line reply wants a bubble.

Best practices

Anatomy

Part Required Description
Bubble yes The surface itself. Holds the variant, the side, and the tail.
BubbleReactions no The row of reaction pills. Under the bubble it sits at the message column's small gap, so it reads as belonging to that message; as the bubble's last child it sits inside, under the text, and the pills become soft chips.
BubbleReaction no One reaction pill — emoji, count (hidden at 1), and pressed state. Celebrates when it becomes the reader's own.
BubbleReactionAdd no The add-reaction pill at the end of the row: opens a ReactionPicker above it.

Subcomponents

Name Type Description
BubbleReactions { align?: "start" | "end" } & ComponentPropsWithRef<"div"> Row container for reaction pills. Match align to the Bubble so the row hangs off the same edge.
BubbleReaction { emoji: ReactNode; label?: string; count?: number; active?: boolean; avatars?: ReactNode; motion?: MotionLevel } & ComponentPropsWithRef<"button"> One reaction pill. A toggle, not a label: active drives aria-pressed as well as the styling, label names it ("Party, 3"), and count is hidden at 1 because the pill already says "one". When it turns on — pressed, or newly added already on — the emoji blooms, copies of it burst out and the count rolls; pills the page loads with stay still. avatars takes the Avatars of the people who reacted: with up to three the pill shows their faces in place of the count, past three the count (count defaults to their number). Inside a Bubble the pill is a soft chip a faint step off the bubble, tinted with primary when it is the reader's own.
BubbleReactionAdd { reactions?: Reaction[]; selected?: string[]; onSelect?: (emoji: string) => void; label?: string; motion?: MotionLevel } & ComponentPropsWithRef<"button"> The add-reaction pill: a smiley that opens a ReactionPicker above it. Choosing an emoji closes the picker and calls onSelect; add the emoji to the row and its new pill celebrates on arrival.

Props

Name Type Default Description
variant "muted" | "primary" | "tint" | "outline" | "plain" "muted" Surface treatment. The usual pair: tint for the reader's own messages (a wash of the brand colour over the thread's surface) and outline for the other person. plain for long-form assistant output that should not sit in a box (also drops the measure cap and padding). muted (other party) and primary (own) are the heavier pair, for a busy or dark surface.
align "start" | "end" "start" Which side of the conversation the bubble is on — puts the tail on the speaker's side. Match it to the enclosing Message.
tail boolean true Draw the tail: a small ear off the speaker-side top corner, which goes square to meet it. The same 5px in every theme's radius language, flat through fully pilled. The bubble keeps the ear's space either way, so turning it off for the continuation bubbles in a grouped run keeps the run aligned.
...div props ComponentPropsWithRef<"div"> — Spread onto the surface element.

Variants

Tokens used

muted, foreground, primary, primary-foreground, border, card, card-foreground, accent, accent-foreground, muted-foreground, ring

Motion

Accessibility

Related

Examples

Two sides

import { Bubble, Message } from "@sableui/react"

<>
	<Message messageId="m1"><Bubble variant="outline">Did the deploy finish?</Bubble></Message>
	<Message messageId="m2" align="end"><Bubble variant="tint" align="end">Green across the board.</Bubble></Message>
</>

Long-form assistant output

import { AgentAvatar, Bubble, CodeBlock, Message } from "@sableui/react"

<Message messageId="a1" avatar={<AgentAvatar size="sm" />}>
	<Bubble variant="plain" className="space-y-3">
		<p className="text-body-md text-foreground">Three things changed in this release:</p>
		<CodeBlock code={diff} filename="CHANGELOG.md" />
	</Bubble>
</Message>

With reactions

import { Bubble, BubbleReaction, BubbleReactionAdd, BubbleReactions, Message } from "@sableui/react"

<Message messageId="m3">
	<Bubble>Shipped 0.45.0.</Bubble>
	<BubbleReactions>
		<BubbleReaction emoji="🎉" label="Party" count={3} active onClick={() => toggle("🎉")} />
		<BubbleReaction emoji="👀" label="Eyes" count={1} onClick={() => toggle("👀")} />
		<BubbleReactionAdd selected={mine} onSelect={toggle} />
	</BubbleReactions>
</Message>

A grouped run drops the repeated tail

import { Bubble, Message } from "@sableui/react"

<>
	<Message messageId="m1" align="end"><Bubble variant="tint" align="end">One more thing.</Bubble></Message>
	<Message messageId="m2" align="end" grouped><Bubble variant="tint" align="end" tail={false}>The staging cert expires Friday.</Bubble></Message>
</>