Skip to content
Version 2.32.0
↓ Get the launcher

BubbleElement record

A content-hugging rounded “chat bubble” / card: a FillColor-tinted rounded sliced background (the same rounded chip sprite SelectableElement draws) hosting a single Child with inner padding. Unlike SelectableElement — which is forced to stretch the full column width — a bubble’s width HUGS its child’s preferred width, so a short label makes a narrow bubble and a long sentence makes a wide one, capped at MaxWidth (or the available width) past which a wrapping TextElement child flows to multiple lines and the bubble grows in height. Built for a game-style chat UI (translucent fills + right-aligned self rows). It is a PURELY VISUAL container: it does not intercept clicks (its background is not a raycast target), so to make a bubble clickable, wrap it in a SelectableElement (or place a ButtonElement beside it) — the bubble renders on top of the selectable’s own tint.

⚠️ Content-hug needs a layout parent that does NOT force-expand child width. A RowElement’s layout respects the child’s intrinsic width, so place a bubble inside a Row (right-align a self bubble with Right + a weighted gutter). Dropped DIRECTLY into a ColumnElement (which force-expands width) the bubble fills the column width instead of hugging — same gotcha as a fixed-size icon (see WindowBuilder-Patterns.md).

public record BubbleElement : IEquatable<HudElement>
name description
BubbleElement(…) A content-hugging rounded “chat bubble” / card: a FillColor-tinted rounded sliced background (the same rounded chip sprite SelectableElement draws) hosting a single Child with inner padding. Unlike SelectableElement — which is forced to stretch the full column width — a bubble’s width HUGS its child’s preferred width, so a short label makes a narrow bubble and a long sentence makes a wide one, capped at MaxWidth (or the available width) past which a wrapping TextElement child flows to multiple lines and the bubble grows in height. Built for a game-style chat UI (translucent fills + right-aligned self rows). It is a PURELY VISUAL container: it does not intercept clicks (its background is not a raycast target), so to make a bubble clickable, wrap it in a SelectableElement (or place a ButtonElement beside it) — the bubble renders on top of the selectable’s own tint.
Child { get; set; } The content laid out inside the bubble (e.g. a wrapping TextElement).
CornerRadius { get; set; } Corner radius in px. 0 (default) reuses the shared 3-radius rounded chip sprite (the SelectableElement chip); a positive value bakes a rounder sliced sprite at that radius (cached per radius, theme-independent). Use ~8–12 for a softer game-style bubble. Note the sliced background’s minimum size is 2r+2, so for a perfectly round bubble (or capsule) of side S use r = S/2 − 1 (e.g. 13 for 28 px); a larger r makes the bubble 2 px taller than its content. The value is used as given — it is not capped.
FillColor { get; set; } Bubble fill colour; the ALPHA is honoured so translucent tints work (the typical chat-bubble look). Null (default) = a sensible themed default (the menu accent at a soft alpha, re-tinted on a theme change so the four presets track).
FillColorFn { get; set; } Per-refresh fill colour, mirroring FillColorFn: evaluated every HUD refresh so the bubble can re-tint live (e.g. a chat channel tab lighting up when it becomes active) without rebuilding the element tree. Non-null wins over the static FillColor; returning null falls back to FillColor (then the themed default). Default null = unchanged: a bubble that leaves it null renders with the static fill exactly as before, no override machinery attached. Added as an init property (NOT a ctor param) so the record stays source + binary compatible with already-compiled plugins.
MaxWidth { get; set; } Hard width cap in px (canvas units). 0 (default) = clamp to the parent/available width instead of a fixed cap. When the child’s natural (unwrapped) width exceeds the cap the bubble fixes at the cap and the child’s wrapping text flows to multiple lines; below the cap the bubble hugs the child’s width. For a right-aligned self row set an explicit cap (e.g. ~70% of the chat window) — a content-sized Row has no definite “available width” to clamp to.
OutlineColorFn { get; set; } Per-refresh OUTLINE colour: a thin (1 px) ring drawn along the bubble’s rounded edge, following the same CornerRadius. Evaluated every refresh; a colour shows the ring in it (alpha honoured), null hides it — so a bubble can light up a state border (e.g. “busy”, “translated”) without rebuilding the tree. The ring is overlaid (never measured), so toggling it never changes the bubble’s size. Default null = no ring is even created: the bubble renders exactly as before. An init property (binary-compatible).
PaddingX { get; set; } Inner horizontal padding (each side) in px between the bubble edge and its child. Default 10.
PaddingY { get; set; } Inner vertical padding (top and bottom) in px between the bubble edge and its child. Default 6.