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.
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'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
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
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
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
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
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
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
import { Component, ViewEncapsulation } from '@angular/core';import { ScBubble, ScBubbleContent, ScBubbleReactions, ScButton, ScTooltip, ScTooltipArrow, ScTooltipPortal, ScTooltipProvider,Popover
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).
| Part | Selector | Description |
|---|---|---|
ScBubbleGroup | div[scBubbleGroup] | Consecutive bubbles from the same sender, closer together. |
ScBubble | div[scBubble] | variant ('default', 'secondary', 'muted', 'tinted', 'outline', 'ghost', 'destructive'), align ('start', 'end'). Up to 80% wide; ghost: full width. |
ScBubbleContent | div[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. |
ScBubbleReactions | div[scBubbleReactions] | Reactions or buttons over the edge: side ('bottom', 'top'), align ('end', 'start'). Leave room for them. |