General
Bubble
Usage#
import { WDS_BUBBLE } from '@wds/angular/bubble';Examples#
Default#
align="end" moves the user's own bubbles to the end of the row. A bubble is at most 80% wide.
import { Component } from '@angular/core';
import { WdsBubbleComponent, WdsBubbleContentComponent } from '@wds/angular/bubble';
@Component({
selector: 'app-bubble-default-demo',
imports: [WdsBubbleComponent, WdsBubbleContentComponent],
template: `
<div class="flex w-full max-w-sm flex-col gap-3">
<wds-bubble variant="muted">
<wds-bubble-content>Hi! My train to Gdaลsk was cancelled. Can I use the ticket on the next one?</wds-bubble-content>
</wds-bubble>
<wds-bubble align="end">
<wds-bubble-content>Yes, the ticket is valid on any train on that route today.</wds-bubble-content>
</wds-bubble>
<wds-bubble variant="muted">
<wds-bubble-content>Great, thanks.</wds-bubble-content>
</wds-bubble>
</div>
`,
})
export class BubbleDefaultDemo {}Variants#
default, secondary, muted, tinted, outline, destructive and ghost (no bubble, the full width of the row).
import { Component } from '@angular/core';
import { WdsBubbleComponent, WdsBubbleContentComponent } from '@wds/angular/bubble';
@Component({
selector: 'app-bubble-variants-demo',
imports: [WdsBubbleComponent, WdsBubbleContentComponent],
template: `
<div class="flex w-full max-w-sm flex-col gap-3">
<wds-bubble><wds-bubble-content>Default: the user's own message.</wds-bubble-content></wds-bubble>
<wds-bubble variant="secondary"><wds-bubble-content>Secondary: a status update.</wds-bubble-content></wds-bubble>
<wds-bubble variant="muted"><wds-bubble-content>Muted: a message from someone else.</wds-bubble-content></wds-bubble>
<wds-bubble variant="tinted"><wds-bubble-content>Tinted: a shade of the primary color.</wds-bubble-content></wds-bubble>
<wds-bubble variant="outline"><wds-bubble-content>Outline: on a busy background.</wds-bubble-content></wds-bubble>
<wds-bubble variant="destructive"><wds-bubble-content>Destructive: the message could not be sent.</wds-bubble-content></wds-bubble>
<wds-bubble variant="ghost"><wds-bubble-content>Ghost: no bubble at all, the full width of the row, for long answers.</wds-bubble-content></wds-bubble>
</div>
`,
})
export class BubbleVariantsDemo {}Group#
wds-bubble-group keeps consecutive bubbles from one sender closer together.
import { Component } from '@angular/core';
import { WdsBubbleComponent, WdsBubbleContentComponent, WdsBubbleGroupComponent } from '@wds/angular/bubble';
@Component({
selector: 'app-bubble-group-demo',
imports: [WdsBubbleGroupComponent, WdsBubbleComponent, WdsBubbleContentComponent],
template: `
<div class="flex w-full max-w-sm flex-col gap-6">
<wds-bubble-group>
<wds-bubble variant="muted"><wds-bubble-content>The 7:40 from Krakรณw is running late.</wds-bubble-content></wds-bubble>
<wds-bubble variant="muted"><wds-bubble-content>About 15 minutes, a signal fault near Tarnรณw.</wds-bubble-content></wds-bubble>
</wds-bubble-group>
<wds-bubble-group>
<wds-bubble align="end"><wds-bubble-content>Thanks for the heads-up.</wds-bubble-content></wds-bubble>
<wds-bubble align="end"><wds-bubble-content>Will I still make the connection in Katowice?</wds-bubble-content></wds-bubble>
</wds-bubble-group>
</div>
`,
})
export class BubbleGroupDemo {}Reactions#
wds-bubble-reactions hangs a pill off the bottom or top edge (side) at the start or end (align). Static emoji get role="img" and an aria-label; with a button the pill is the button. Leave more space between bubbles with reactions.
import { Component } from '@angular/core';
import { WdsCardComponent } from '@wds/angular/card';
import { WdsBubbleComponent, WdsBubbleContentComponent, WdsBubbleReactionsComponent } from '@wds/angular/bubble';
import { WdsButtonComponent } from '@wds/angular/button';
@Component({
selector: 'app-bubble-reactions-demo',
imports: [WdsCardComponent, WdsBubbleComponent, WdsBubbleContentComponent, WdsBubbleReactionsComponent, WdsButtonComponent],
template: `
<wds-card class="w-full max-w-sm">
<div class="flex flex-col gap-8">
<wds-bubble variant="secondary">
<wds-bubble-content>Platform changes now show up in the app.</wds-bubble-content>
<wds-bubble-reactions role="img" aria-label="Reactions: thumbs up, party popper">
<span>๐</span>
<span>๐</span>
</wds-bubble-reactions>
</wds-bubble>
<wds-bubble align="end">
<wds-bubble-content>Rolling it out to all stations tomorrow.</wds-bubble-content>
<wds-bubble-reactions align="start">
<wds-button variant="ghost" size="xs" aria-pressed="false" label="React with a party popper, 3 so far">๐ 3</wds-button>
</wds-bubble-reactions>
</wds-bubble>
<wds-bubble variant="muted">
<wds-bubble-content>The timetable PDF is updated too.</wds-bubble-content>
<wds-bubble-reactions side="top" align="start" role="img" aria-label="Reaction: eyes">
<span>๐</span>
</wds-bubble-reactions>
</wds-bubble>
</div>
</wds-card>
`,
})
export class BubbleReactionsDemo {}Quick replies#
interactive makes the content a button and href a link, both with a hover color and a focus ring.
import { Component } from '@angular/core';
import { WdsBubbleComponent, WdsBubbleContentComponent } from '@wds/angular/bubble';
@Component({
selector: 'app-bubble-quick-replies-demo',
imports: [WdsBubbleComponent, WdsBubbleContentComponent],
template: `
<div class="flex w-full max-w-sm flex-col gap-3">
<wds-bubble variant="muted">
<wds-bubble-content>Which ticket do you need help with?</wds-bubble-content>
</wds-bubble>
<div class="flex flex-wrap justify-end gap-2" role="group" aria-label="Quick replies">
<wds-bubble variant="outline" align="end"><wds-bubble-content interactive>Single ticket</wds-bubble-content></wds-bubble>
<wds-bubble variant="outline" align="end"><wds-bubble-content interactive>Monthly pass</wds-bubble-content></wds-bubble>
<wds-bubble variant="outline" align="end"><wds-bubble-content href="#">Refund policy</wds-bubble-content></wds-bubble>
</div>
</div>
`,
})
export class BubbleQuickRepliesDemo {}API References#
wds-bubble#
wds-bubble-content with the text and optionally wds-bubble-reactions. The variant colors the
content; align="end" moves the bubble to the end of the row (the sender's own messages). Up to 80% wide,
ghost takes the full width (e.g. an assistant answer).
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
| variant | WdsBubbleVariant | 'default' | |
| align | WdsBubbleAlign | 'start' | end moves the bubble to the end of the row. Inside wds-message the message alignment is used. |
Slots
| Slot | Description |
|---|---|
| (default) | wds-bubble-content elements and wds-bubble-reactions. |
CSS custom properties
| Property | Description |
|---|---|
| --wds-bubble-max-width | ghost: 100%). |
wds-bubble-content#
variant of wds-bubble. With href it is a link and with
interactive a button (e.g. a quick reply); both get a hover color and a focus ring.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
| href | string | undefined | ||
| target | string | undefined | _blank. | |
| interactive | boolean | false | click on the element. |
Slots
| Slot | Description |
|---|---|
| (default) |
CSS parts (::part)
| Part | Description |
|---|---|
| content | div, a or button). |
wds-bubble-reactions#
wds-bubble. Static emoji need a name for screen readers
(role="img" and aria-label on the element); with a button inside the pill drops its padding and the button
is the hit area. Leave extra space between bubbles with reactions, the pill sticks out three quarters of its height.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
| side | WdsBubbleReactionsSide | 'bottom' | |
| align | WdsBubbleReactionsAlign | 'end' |
Slots
| Slot | Description |
|---|---|
| (default) | wds-button. |
wds-bubble-group#
Slots
| Slot | Description |
|---|---|
| (default) | wds-bubble elements. |
CSS custom properties
| Property | Description |
|---|---|
| --wds-bubble-group-gap |
Accessibility#
Screen reader#
wds-message-header), because alignment and color are not announced.
wds-bubble-content with interactive is a native <button>, with href a native <a>.
role="img" and an aria-label that lists them; a reaction button needs a label with the count and aria-pressed.
Keyboard support#
| Key | Function |
|---|---|