Skip to content
All components
Conversation

Bubble

Render the content of a conversation turn on a surface that separates it from other turns, with optional reactions attached to it.

The bubble itself. The variant paints the content, not the wrapper.

Installation

tdpxl is not an npm dependency of your app. The @tdpxl/cli command (not published to npm yet) copies the source into your project, with the registry items and npm packages it imports.

npx @tdpxl/cli add bubble

Then import it from @/components/ui/bubble. New project? Start with the installation guide.

Examples

Each example is one branch of the official demo, rendered in its own frame. The code is that branch as you would write it, with imports pointing at the default install paths.

Conversation

Compare message bubbles within the complete conversation composition. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

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

export function BubbleConversation() {
  return (
    <div className="flex w-full max-w-md flex-col gap-6">
      <BubbleGroup>
        <Bubble variant="muted">
          <BubbleContent>How does dark mode work here?</BubbleContent>
        </Bubble>
        <Bubble variant="primary" align="end">
          <BubbleContent>
            Roles point at a different ramp step. No component changes.
          </BubbleContent>
          <BubbleReactions>
            <span>👍</span>
            <span>2</span>
          </BubbleReactions>
        </Bubble>
      </BubbleGroup>
    </div>
  )
}

Muted

Use the muted bubble appearance. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

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

export function BubbleMuted() {
  return (
    <div className="flex w-full max-w-md flex-col gap-6">
      <BubbleGroup>
        <Bubble variant="muted">
          <BubbleContent>How does dark mode work here?</BubbleContent>
        </Bubble>
      </BubbleGroup>
    </div>
  )
}

Primary with reactions

Compose a primary bubble with its reactions. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

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

export function BubblePrimaryWithReactions() {
  return (
    <div className="flex w-full max-w-md flex-col gap-6">
      <BubbleGroup>
        <Bubble variant="primary" align="end">
          <BubbleContent>
            Roles point at a different ramp step. No component changes.
          </BubbleContent>
          <BubbleReactions>
            <span>👍</span>
            <span>2</span>
          </BubbleReactions>
        </Bubble>
      </BubbleGroup>
    </div>
  )
}

Neutral

Use the neutral bubble appearance. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

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

export function BubbleNeutral() {
  return (
    <div className="flex w-full max-w-md flex-col gap-6">
      <div className="flex flex-col gap-2">
        <Bubble variant="neutral">
          <BubbleContent>neutral</BubbleContent>
        </Bubble>
      </div>
    </div>
  )
}

Tinted

Use the tinted bubble appearance. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

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

export function BubbleTinted() {
  return (
    <div className="flex w-full max-w-md flex-col gap-6">
      <div className="flex flex-col gap-2">
        <Bubble variant="tinted">
          <BubbleContent>tinted</BubbleContent>
        </Bubble>
      </div>
    </div>
  )
}

Ghost

Use the ghost bubble appearance. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

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

export function BubbleGhost() {
  return (
    <div className="flex w-full max-w-md flex-col gap-6">
      <div className="flex flex-col gap-2">
        <Bubble variant="ghost">
          <BubbleContent>ghost, for an answer that is just text</BubbleContent>
        </Bubble>
      </div>
    </div>
  )
}

Long unbroken text

Wrap a long unbroken string inside the bubble instead of overflowing. Content breaks anywhere when it has to, so identifiers and links never widen the conversation. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

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

export function BubbleLongUnbrokenText() {
  return (
    <div className="flex w-full max-w-md flex-col gap-6">
      <div className="flex max-w-xs flex-col">
        <Bubble variant="muted">
          <BubbleContent>
            The failing build is
            7f3a9c2e5b1d4f8a6c0e2b9d7f1a3c5e8b0d2f4a6c8e0b2d4f6a8c0e2b4d6f8a
            on the staging branch.
          </BubbleContent>
        </Bubble>
      </div>
    </div>
  )
}

Labelled reactions

Give reactions a readable text alternative. The emoji and count are hidden from assistive technology and replaced by a sentence that names the reaction. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

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

export function BubbleLabelledReactions() {
  return (
    <div className="flex w-full max-w-md flex-col gap-6">
      <div className="flex flex-col pt-4">
        <Bubble variant="muted">
          <BubbleContent>The venue for Thursday is confirmed.</BubbleContent>
          <BubbleReactions side="top" align="start">
            <span aria-hidden="true">🎉 3</span>
            <span className="sr-only">3 reactions: party popper</span>
          </BubbleReactions>
        </Bubble>
      </div>
    </div>
  )
}

Multiline

Preserve line breaks in message text. BubbleContent keeps authored new lines, so short lists stay readable without extra markup. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

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

export function BubbleMultiline() {
  return (
    <div className="flex w-full max-w-md flex-col gap-6">
      <div className="flex flex-col">
        <Bubble variant="tinted">
          <BubbleContent>{`Agenda for Monday:
      1. Budget review
      2. Hiring plan
      3. Open questions`}</BubbleContent>
        </Bubble>
      </div>
    </div>
  )
}

API reference

Generated from the component's TypeScript signatures. Inherited DOM and primitive props are listed separately.

Bubble

Group the visible content and reactions of a conversation message.

Bubble props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
variant"primary" | "neutral" | "ghost" | "muted" | "tinted" | null | undefined"primary"Message surface treatment: primary, neutral, ghost, muted or tinted. Message authorship and status must remain understandable from content.
align"start" | "end" | undefined"start"Align the bubble or its reactions to the start or end of their layout.
Inherited props (13)
Bubble inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLDivElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLDivElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLDivElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLDivElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLDivElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

BubbleContent

Content region within the root composition. Keep required providers, labels and related controls from the complete example.

BubbleContent props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (13)
BubbleContent inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLDivElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLDivElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLDivElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLDivElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLDivElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

BubbleGroup

Group related parts while preserving the parent component's required composition.

BubbleGroup props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (13)
BubbleGroup inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLDivElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLDivElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLDivElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLDivElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLDivElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

BubbleReactions

The BubbleReactions part of bubble. Use it with the complete source composition and preserve its required parent context.

BubbleReactions props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
side"top" | "bottom" | null | undefined"bottom"Place reactions above or below their bubble.
align"start" | "end" | null | undefined"end"Align the bubble or its reactions to the start or end of their layout.
Inherited props (13)
BubbleReactions inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLDivElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLDivElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLDivElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLDivElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLDivElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

Accessibility & usage

From registry/ui/bubble.meta.json (authored guidance; human review may still be pending). Behavior is checked by Storybook tests, not certified here.

When to use

  • Text, short lists or inline media of a chat or support message, usually inside Message.
  • Telling sides of a conversation apart with surface treatment (filled for the user, muted for others, ghost for long assistant answers).
  • Showing reactions attached to a specific message.

When not to use

  • Long-form assistant answers with headings, tables or code; a ghost bubble or plain content reads better than a narrow filled bubble.
  • System notices, dates or dividers; use a marker.
  • Highlighting or callouts outside a conversation; use an alert or card.

Anatomy

BubbleGroup
A tight vertical stack for consecutive bubbles from the same author.
Bubble
The wrapper: variant (primary, neutral, muted, tinted, ghost) paints the content, not the wrapper; align="end" moves it to the end side; at most 80% wide except ghost.
BubbleContent
The painted surface with the message text; preserves line breaks and breaks long words.
BubbleReactions
A small badge positioned on the bubble edge (side top or bottom, align start or end) for reactions; passive content.

Keyboard & interaction

  • Bubbles are passive and not focusable; links or buttons inside the content keep their own keyboard behavior.
  • BubbleReactions is not a button and has no live region; if reacting is interactive, render buttons inside it with names such as 'Party popper, 3 reactions, you reacted'.
  • Selecting and copying text works natively; do not block selection on message content.

Responsive behavior

  • The 80% maximum width keeps author sides recognizable on phones; ghost bubbles use the full width for long answers.
  • Content wraps anywhere when it must, so long identifiers and links never widen the conversation at 320 CSS pixels.
  • Reactions overlap the bubble edge; leave vertical space between bubbles (or use side top on the first message) so they do not cover neighbouring content.

Content guidelines

  • Keep message text as written, including line breaks; do not truncate messages.
  • Use plain text for short lists and preserve new lines rather than forcing markup.
  • Give each reaction group an accessible sentence: count, reaction name and whether the current user reacted.
  • Make links descriptive where possible; raw URLs are acceptable in chat but must wrap.

Alternatives

  • Message — The full turn layout with author, avatar, header and footer around the bubble.
  • Marker — A label for a position in the conversation rather than a turn.
  • Alert — A status message outside the flow of a conversation.

Resources