Skip to content
GitHub11 stars

Displays conversational content in a message bubble. Supports variants, alignment, grouping, reactions, and collapsible content.

Hey there! what's up?
Hey! Want to see chat bubbles?
I can group messages, switch sides, and keep the whole thread easy to scan.
Sure. Hit me with your best demo.
Yes. You are reading a demo that is demoing itself. Very meta. Very on-brand.
<div class="flex w-full max-w-sm flex-col gap-8 py-12">
    <Bubble Align="BubbleAlign.End"><BubbleContent>Hey there! what&apos;s up?</BubbleContent></Bubble>
    <BubbleGroup>

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

dnx Blazix.Cli add bubble

Usage

<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
    └── BubbleContent

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 parameter on every part

Variants

Use Variant to change the visual treatment of the bubble.

This is the default primary bubble.
This is the secondary variant.
This one is muted. It uses a lower emphasis color for the chat bubble.
This one is tinted. The tint is a softer color derived from the primary color.
We can also use an outlined variant.
Or a destructive variant with a reaction.

Ghost bubbles work for assistant text, markdown, and other content that should not be framed.

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 in it.

Ghost bubbles are full width and can take the full width of the container.

<div class="flex w-full max-w-sm flex-col gap-12 py-12">
    <Bubble>
        <BubbleContent>This is the default primary bubble.</BubbleContent>
VariantDescription
defaultA strong primary bubble, usually for the current user.
secondaryThe standard neutral bubble for conversation content.
mutedA lower-emphasis bubble for quiet supporting content.
tintedA subtle primary-tinted bubble.
outlineA bordered bubble for secondary or rich content.
ghostUnframed content for assistant text or rich content.
destructiveA destructive bubble for error or failed actions.

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.

This bubble is aligned to the start. This is the default alignment.
This bubble is aligned to the end. Use this for user messages.
<div class="flex w-full max-w-sm flex-col gap-8 py-12">
    <Bubble Variant="BubbleVariant.Muted">
        <BubbleContent>This bubble is aligned to the start. This is the default alignment.</BubbleContent>
    </Bubble>
    <Bubble Align="BubbleAlign.End">
        <BubbleContent>This bubble is aligned to the end. Use this for user messages.</BubbleContent>
    </Bubble>
</div>
alignDescription
startAlign the bubble to the start of the conversation.
endAlign the bubble to the 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 parameter 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 parameter should be set on the Bubble component itself, not the BubbleGroup component.

BubbleGroup
├── Bubble
│   └── BubbleContent
└── Bubble
    └── BubbleContent
Can you tell me what's the issue?
You tell me!
It worked yesterday. You broke it!
Find the bug and fix it.
👀
Want me to diff yesterday's you against today's you? It's a bit embarrassing.
<div class="flex w-full max-w-sm flex-col gap-8 py-12">
    <Bubble Variant="BubbleVariant.Muted">
        <BubbleContent>Can you tell me what&apos;s the issue?</BubbleContent>

You can turn a bubble into a link or button by using the Render parameter on BubbleContent.

How can I help you today?
@inject ToastManager Toasts

<div class="flex w-full max-w-sm flex-col gap-8 py-12">
<Bubble Variant="BubbleVariant.Muted">
    <BubbleContent>
        <Render Context="content">
            <button @attributes="content.Attributes" type="button">Click here</button>
        </Render>
    </BubbleContent>
</Bubble>

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="BubbleReactionsSide.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.

I don't need tests, I know my code works.
Bold. Fine I'll add some tests. I'll let you know when they're done.
Tests passed on the first try. All 142 of them. Looking good!
Are you sure I can run this command?
@inject ToastManager Toasts

<div class="flex w-full max-w-sm flex-col gap-12 py-12">

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.

How can I help you today?
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...
<div class="flex w-full max-w-sm flex-col gap-8 py-12">
    <Bubble Variant="BubbleVariant.Muted">
        <BubbleContent>How can I help you today?</BubbleContent>

Tooltip

Wrap a bubble in a Tooltip to reveal metadata on hover, such as when a message was read.

Did you remove the stale route?
Yes, removed it from the registry.
<div class="flex w-full max-w-sm flex-col gap-4 py-12">
    <Bubble Variant="BubbleVariant.Secondary"><BubbleContent>Did you remove the stale route?</BubbleContent></Bubble>
    <Bubble Align="BubbleAlign.End">

Popover

Pair a bubble with a Popover to surface more information on demand, such as the full error message for a failed action.

Run the build script.
Failed to run the command.
<div class="flex w-full max-w-sm flex-col gap-4 py-12">
    <Bubble Align="BubbleAlign.End"><BubbleContent>Run the build script.</BubbleContent></Bubble>
    <Bubble Variant="BubbleVariant.Destructive">

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="ButtonVariant.Secondary" Size="ButtonSize.IconXs">
        <Icon Data="LucideIcons.ThumbsUp" />
    </Button>
</BubbleReactions>

Interactive Bubbles

When a bubble is clickable, render it as a real <button> or <a> with the Render parameter 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="BubbleVariant.Muted" Align="BubbleAlign.End">
    <BubbleContent>
        <Render Context="content">
            <button @attributes="content.Attributes" type="button" @onclick="Reply">I forgot my password</button>
        </Render>
    </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.

RTL

To enable RTL support in Blazix, see the RTL configuration guide.

Translated with AI for the demo, so it may have mistakes.

مرحبًا! ما الأخبار؟
مرحبًا! هل تريد أن ترى فقاعات الدردشة؟
يمكنني تجميع الرسائل، وتبديل الجوانب، وإبقاء المحادثة بأكملها سهلة القراءة.
بالتأكيد. أرني أفضل عرض لديك.
نعم. أنت تقرأ عرضًا يعرض نفسه. أمر طريف حقًا.
@* Align.End puts your own messages at the end of the reading direction: the left in RTL. *@
<div class="flex w-full max-w-sm flex-col gap-8 py-12">
    <Bubble Align="BubbleAlign.End"><BubbleContent>@T.Hey</BubbleContent></Bubble>

API Reference

Bubble

ParameterTypeDefault
Variant BubbleVariant BubbleVariant.Default
Align BubbleAlign BubbleAlign.Start
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

BubbleContent

ParameterTypeDefault
Render RenderFragment<UseRenderProps>? -
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

BubbleGroup

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

BubbleReactions

ParameterTypeDefault
Align BubbleAlign BubbleAlign.End
Side BubbleReactionsSide BubbleReactionsSide.Bottom
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.