Bubble

A message's surface in a conversation: at the start or the end, in a variant, with reactions. In the look of the app's style.

Data DisplayExperimental

Usage

import { Component, ViewEncapsulation } from '@angular/core';import {  ScBubble,  ScBubbleContent,  ScBubbleGroup,  ScBubbleReactions,} from '@semantic-components/ui';
@Component({  selector: 'app-bubble-usage-demo',  imports: [ScBubbleGroup, ScBubble, ScBubbleContent, ScBubbleReactions],  template: `    <div class="flex w-full max-w-sm flex-col gap-8 py-6">      <div scBubble alignment="end">        <div scBubbleContent>Hey there! What&apos;s up?</div>      </div>      <div scBubbleGroup>        <div scBubble variant="muted">          <div scBubbleContent>Hey! Want to see chat bubbles?</div>        </div>        <div scBubble variant="muted">          <div scBubbleContent>            I can group messages, switch sides, and keep the whole thread easy            to scan.          </div>          <div scBubbleReactions role="img" aria-label="Reaction: thumbs up">            <span>👍</span>          </div>        </div>      </div>      <div scBubble alignment="end">        <div scBubbleContent>Sure. Hit me with your best demo.</div>      </div>      <div scBubble variant="muted">        <div scBubbleContent>          Yes. You are reading a demo that is demoing itself. Very meta.        </div>        <div          scBubbleReactions          role="img"          aria-label="Reactions: thumbs up, fire, eyes, and 2 more"        >          <span>👍</span>          <span>🔥</span>          <span>👀</span>          <span>+2</span>        </div>      </div>    </div>  `,  host: { class: 'flex w-full justify-center' },  encapsulation: ViewEncapsulation.None,})export class BubbleUsageDemo {}

Anatomy

Every part is a directive on your element; the text, the reactions and their names are yours. A message's avatar, name and time belong to Message, around it.

import {  ScBubbleGroup, ScBubble, ScBubbleContent, ScBubbleReactions,} from '@semantic-components/ui';
<div scBubbleGroup>  <div scBubble variant="…" alignment="…">    <div scBubbleContent>…</div>    <div scBubbleReactions role="img" aria-label="…">…</div>  </div></div>

Accessibility

  • A row of emoji is one image: give it role="img" and an aria-label ("Reactions: thumbs up, fire, and 8 more") — otherwise each glyph is read alone, and "+8" as "plus eight".
  • Reactions that are buttons: name each, an icon-only one in sr-only text.
  • A clickable bubble is a real button or link (scBubbleContent on it): focusable, with a focus ring, named by its text.
  • Don't let the colour carry the meaning: a destructive bubble says what failed in its text.

Examples

Variants

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 and other content that should not be framed. They take the full width of the container.
import { Component, ViewEncapsulation } from '@angular/core';import {  ScBubble,  ScBubbleContent,  ScBubbleReactions,} from '@semantic-components/ui';
/** variant colours the content: default (primary), secondary, muted, tinted, outline, ghost (unframed, full width), destructive. */@Component({  selector: 'app-variants-bubble-demo',

Alignment

This bubble is aligned to the start. This is the default alignment.
This bubble is aligned to the end. Use this for user messages.
import { Component, ViewEncapsulation } from '@angular/core';import { ScBubble, ScBubbleContent } from '@semantic-components/ui';
/** alignment: start (default) or end, for your own messages. Inline: it follows the direction. */@Component({  selector: 'app-alignment-bubble-demo',  imports: [ScBubble, ScBubbleContent],  template: `    <div class="flex w-full max-w-sm flex-col gap-8 py-6">      <div scBubble variant="muted">

Group

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.
import { Component, ViewEncapsulation } from '@angular/core';import {  ScBubble,  ScBubbleContent,  ScBubbleGroup,  ScBubbleReactions,} from '@semantic-components/ui';
/** Consecutive bubbles from the same sender, closer together; align goes on each bubble. */@Component({

Links and buttons

How can I help you today?
import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScBubble,  ScBubbleContent,  ScBubbleGroup,  ScFrame,} from '@semantic-components/ui';
/** scBubbleContent on a button or a link: the whole bubble is clickable, named by its text. */@Component({

Reactions

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?
import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScBubble,  ScBubbleContent,  ScBubbleReactions,  ScButton,  ScFrame,} from '@semantic-components/ui';
/** side (bottom, top) and align (end, start). They overlap the edge: leave room between rows (gap-12). Emoji: one image, named; buttons: named. */

Show more

How can I help you today?

The accessibility review found two focus states that were visually too subtle in dark mode.

import { Component, ViewEncapsulation } from '@angular/core';import {  ScBubble,  ScBubbleContent,  ScButton,  ScCollapsible,  ScCollapsiblePanel,  ScCollapsibleTrigger,} from '@semantic-components/ui';import { SiChevronDownIcon } from '@semantic-icons/lucide-icons';

Tooltip

Did you remove the stale route?
Yes, removed it from the registry.
import { Component, ViewEncapsulation } from '@angular/core';import {  ScBubble,  ScBubbleContent,  ScBubbleReactions,  ScButton,  ScTooltip,  ScTooltipArrow,  ScTooltipPortal,  ScTooltipProvider,

Popover

Run the build script.
Failed to run the command.
import { Component, ViewEncapsulation } from '@angular/core';import {  ScBubble,  ScBubbleContent,  ScBubbleReactions,  ScButton,  ScPopover,  ScPopoverDescription,  ScPopoverHeader,  ScPopoverPortal,

RTL

مرحبًا! هل تريد أن ترى فقاعات المحادثة؟
بالتأكيد. أرني أفضل عرض لديك.
أنت تقرأ عرضًا يعرض نفسه.
import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation } from '@angular/core';import {  ScBubble,  ScBubbleContent,  ScBubbleReactions,} from '@semantic-components/ui';
/** In a right-to-left page: start is the right, end the left; the reactions follow. */@Component({

API reference

Each part takes class, merged over the style (cn: a later class wins).

PartSelectorDescription
ScBubbleGroupdiv[scBubbleGroup] Consecutive bubbles from the same sender, closer together.
ScBubblediv[scBubble] variant ('default', 'secondary', 'muted', 'tinted', 'outline', 'ghost', 'destructive'), align ('start', 'end'). Up to 80% wide; ghost: full width.
ScBubbleContentdiv[scBubbleContent], button[scBubbleContent], a[scBubbleContent] The text, in the variant’s colours. On a button (type="button") or a link, the whole bubble is clickable.
ScBubbleReactionsdiv[scBubbleReactions] Reactions or buttons over the edge: side ('bottom', 'top'), align ('end', 'start'). Leave room for them.