Skip to content

Bubble ​

The message bubble surface for conversations: owns only the bubble itself (background/border/radius/max width + content), while avatar, name, time, and delivery state belong to the oas-message-row composition row. For AI assistants, support chats, IM conversations, etc.

Basic Usage ​

Default bubble

Hi, give me an overview of the OAS-UI conversation components.

Content goes into the default slot; width fits content with an 80% container cap (override chain-wide via --oas-bubble-max-width).

Alignment (align) ​

Start / end sides

Their message: aligned to start by default (logical properties, mirrored automatically in RTL).My message: align="end" sticks to the end side, visually split from theirs.

align="start" | "end" is implemented with logical layout (margin-inline-start: auto + text-align: end) — no physical-direction CSS.

Tail ​

Last bubble of a group in a two-sided conversation

GConsecutive messages from the same sender: earlier ones carry no tail.GThe last one sets tail, pointing at its sender next to the avatar.MeMy message has no tail by default.Metail="auto" follows align and points at the sender on the end side.

Variant behavior: outline falls back to a corner, muted / ghost omit the tail

outline: no protruding tail; the bottom outer corner tightens so the border stays continuous.muted: no surface, so no tail.ghost: no surface, so no tail.

tail="none | auto | start | end" (default none). auto follows align: the other party (start) gets a bottom-left tail, my own messages (end) get a bottom-right tail. Filled variants (default / secondary / destructive) draw a curved tail at the bottom outer corner, colored from the bubble surface; outline falls back to a tightened bottom outer corner (no broken border), while muted / ghost have no surface and draw nothing. In grouped conversations, set tail only on the last message of a run from the same sender, matching common chat UIs. The tail is a decorative pseudo-element (not in the DOM or accessibility tree); size, offset and corner radius are tunable via --oas-bubble-tail-size / --oas-bubble-tail-offset / --oas-bubble-tail-corner-radius.

Variants (variant) ​

Six semantic variants

default: neutral soft surface (default).secondary: primary-tinted, typical for my own messages.muted: no fill, secondary text color.outline: filled surface with border.ghost: no fill, no border, width cap lifted.destructive: danger semantics (error echoes etc.).

The tinted surfaces of secondary/destructive mix theme semantic colors via color-mix() (theme-aware) and adapt automatically in dark mode; ghost lifts the 80% width cap for long streaming answers.

Typing (loading) ​

loading typing indicator

Summarize the key points of this document.Simulate replying…

With the boolean loading attribute present, content switches to a three-dot typing indicator (the AI "typing" scenario) and the host element reflects aria-busy; the animation respects prefers-reduced-motion.

streaming means "some content is already visible and more is arriving": content stays visible, the host reflects aria-busy, and the content region uses aria-live="off" to avoid per-token announcements. Remove it when the answer ends and let a host status region announce completion/stop/failure. loading and streaming are different states; do not use loading for streaming append.

Streaming append (streaming)

Part of the answer is visible and more content is still arriving.

Reactions (reactions) ​

Emoji + count (side / align)

I support this plan; let's align on the details.I've confirmed the plan above.

Click a reaction button; the received oas-reaction shows here.

reactions is a JSON array (each item { emoji, count?, active?, label? }, emoji required; an empty array/invalid JSON renders nothing). reactions-side controls top/bottom (default bottom; top places it above the bubble) and reactions-align overrides horizontal alignment (defaults to following the bubble align). Each reaction is a real button (keyboard reachable + focus ring + aria-pressed reflecting the active state): clicking it dispatches oas-reaction (detail { emoji, count, active, index }) — reaction data stays owned by the host, the component only dispatches intent.

Accessibility ​

  • Direction is never conveyed by color/alignment alone: sender name and message text live in oas-message-row's header/content, readable by screen readers.
  • The loading dots carry role="status" with a localized accessible name ("Typing…"); the dots themselves are aria-hidden.
  • Bubbles are purely presentational (no tab stop); rich content (links/buttons) goes into the default slot and keeps native reachability.

API ​

oas-bubble ​

Attributes ​

AttributeDescriptionTypeDefault
alignDirection: start (other party, default) / end (self) — logical-property alignment (align-self, RTL mirrored automatically); when set explicitly it wins over the inherited text-align reflection——
loadingTyping state (boolean presence): content switches to a three-dot typing indicator and the host reflects aria-busy (the AI "typing" scenario)boolean—
reactionsReaction bar as a JSON array; each item { emoji, count?, active?, label? } (emoji required). Empty array / invalid JSON renders nothing——
reactions-alignHorizontal alignment of the reaction bar: start / end; defaults to following the bubble align——
reactions-sideVertical placement of the reaction bar: bottom (default, below the bubble) / top (above the bubble)——
streamingStreaming state (boolean presence): content stays visible and the host reflects aria-busy; the content region uses aria-live=off to avoid per-token announcements, while a host status region announces completion.boolean—
tailTail direction: none (default, no tail) | auto (follow align: start or end side) | start | end — a small curved tail at the bottom outer corner pointing at the sender. Filled variants draw it, outline falls back to a tightened bottom outer corner, and muted / ghost omit it. In grouped conversations set it only on the last message of a run from the same sender.stringnone

Events ​

EventDescription
oas-reactionFired when a reaction is clicked; detail { emoji, count, active, index } (reaction data stays owned by the host)

Slots ​

NameDescription
defaultBubble content

CSS Variables ​

CSS VariableDefault
--oas-bubble-max-width80%
--oas-bubble-radiusvar(--oas-radius-lg)
--oas-bubble-tail-corner-radiusvar(--oas-radius-sm)
--oas-bubble-tail-offset0
--oas-bubble-tail-size16px

Parts: ::part(bubble), ::part(content), ::part(typing), ::part(reactions) reaction strip / ::part(reaction) a single reaction button. align (start default / end) and variant (default / secondary / muted / outline / ghost / destructive) are pure CSS channels.

Released under the MIT OR Apache-2.0 License.