suiss/ui · Component
Bubble
A chat-style message bubble with variants, alignment, a tail and optional reactions.
Bubble is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
A Bubble wraps a BubbleContent, which renders the rounded message body. Add BubbleReactions inside the bubble to pin a reaction pill to its top or bottom edge. Stack bubbles in a BubbleGroup to form a conversation.
Align bubbles to the start or end of the conversation. The tail appears only on the last bubble in a run of consecutive bubbles with the same alignment, and never on the outline or ghost variants. Use Bubble for chat transcripts and assistant replies; for a full message row with avatar and metadata, see Message.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
- Install the following dependencies and add the
cnhelper:
- Copy and paste the following code into your project.
- Update the import paths to match your project setup.
Usage
Composition
Use the following composition to build a Bubble:
Examples
Variants
Use the variant prop to set the background and text color. This shows every variant, from default to destructive.
Conversation
An exchange of incoming muted and outgoing bubbles. Set align="end" for messages sent by the current user and leave the default start for incoming messages.
With reactions
Pin reactions to different corners with the side and align props of BubbleReactions. They default to the bottom-end corner.
Interactive
Render BubbleContent as a button or a for tappable bubbles, such as suggested replies; these get hover and focus styles.
Accessibility
- Bubbles are static content by default and contribute no focusable elements.
- When
BubbleContentrenders abuttonora, it is in the tab order and shows a focus ring. - Reactions are plain content; if they are emoji, consider adding text that screen readers can announce.
API Reference
BubbleGroup
A vertical stack of bubbles.
Also accepts the props of React.ComponentProps<"div">.
Bubble
The positioned wrapper that sets variant and alignment.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "secondary" | "muted" | "tinted" | "outline" | "ghost" | "destructive" | "default" |
align | "start" | "end" | "start" |
Also accepts the props of React.ComponentProps<"div">.
The ghost variant has no background or padding. The tail appears only on the last bubble in a run with the same alignment, and never on outline or ghost. Bubbles are capped at 80% of the container width, except ghost. Bubbles also align to end when inside a message slot with data-align="end". The background is set through the --bubble-bg custom property; set --bubble-surface when bubbles sit on a surface other than --background, so the tail and reaction ring blend in.
BubbleContent
The rounded message body, with the tail.
Also accepts the props of useRender.ComponentProps<"div">.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
Also accepts the props of React.ComponentProps<"div">.
| Prop | Type | Default |
|---|---|---|
render | (props: React.HTMLAttributes<HTMLElement>) => React.ReactNode | — |
Also accepts the props of React.ComponentProps<"div">.
Renders a div by default. Use the render prop to render it as a button or a.
Renders a div by default. Set asChild and pass a button or a as its child to render that element instead.
Renders a div by default. Pass a render function that returns a button or a with the props it receives.
BubbleReactions
A small pill for reactions, overlapping the bubble's edge.
| Prop | Type | Default |
|---|---|---|
align | "start" | "end" | "end" |
side | "top" | "bottom" | "bottom" |
Also accepts the props of React.ComponentProps<"div">.
side picks the edge the pill overlaps and align its position along that edge. The bubble adds margin on that side so reactions do not overlap neighboring bubbles.
Each part sets a data-slot, such as bubble-content, for styling. The bubble also sets data-variant and data-align, and reactions set data-side and data-align.
Web preview
Bubble lays out one message aligned to the start or end of the conversation, and BubbleContent draws the rounded bubble with an SVG tail on the aligned side. Seven variants are available: default (primary), secondary, muted, tinted, outline, ghost and destructive; outline and ghost have no tail.
BubbleGroup stacks messages and shows the tail only on the last bubble of each run from the same side, so consecutive messages read as one block. BubbleReactions pins a small reaction pill to the top or bottom edge of a bubble.
Installation
- Install the following dependencies:
- Copy and paste the following code into
components/ui/bubble.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
- Copy and paste the following code into
components/ui/bubble.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
- Copy and paste the following code into
components/ui/bubble.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Examples
Variants
All seven variants.
Use the variant prop to set the colors.
Web preview
Conversation
A BubbleGroup with messages from both sides and merged tails.
Set align="end" for messages from the current user.
Web preview
With reactions
Reaction pills on the bottom and top edges, placed with the side and align props of BubbleReactions.
Web preview
Interactive
A pressable outline bubble with onPress.
A pressable outline bubble with onClick.
Web preview
Long press actions
A bubble that opens a context menu on long press.
Use render on BubbleContent to attach it to the trigger.

Accessibility
BubbleContentgets thebuttonrole when it hasonPressoronLongPress.- The tail is hidden from VoiceOver and TalkBack.
- Give long-press bubbles an
accessibilityLabelthat says who sent the message.
API Reference
BubbleGroup
Column that decides which bubbles show a tail.
Also accepts the props of ViewProps.
Bubble
One message, aligned to the start or end.
| Prop | Type | Default |
|---|---|---|
variant | BubbleVariant | "default" |
align | BubbleAlign | - |
Also accepts the props of ViewProps.
align is start or end and defaults to start; you can also provide a default through BubbleAlignContext. The tail mirrors itself for end alignment and in right-to-left layouts. Colors follow the system appearance.
BubbleContent
The bubble itself, optionally pressable.
| Prop | Type | Default |
|---|---|---|
render | RenderProp<Record<string, unknown>, Record<string, never>> | - |
Also accepts the props of React.ComponentProps<typeof Pressable>, React.RefAttributes<View>.
Plain strings are wrapped in Text. BubbleContent becomes a Pressable when you pass onPress, onLongPress or render, and it fades to 80% opacity while pressed. render sets the element to render instead of the default view or pressable.
BubbleReactions
Reaction pill on the edge of a bubble.
| Prop | Type | Default |
|---|---|---|
align | BubbleAlign | "end" |
side | "top" | "bottom" | "bottom" |
Also accepts the props of ViewProps.
The bubble adds margin on the reaction side so the pill does not overlap its neighbors.
BubbleVariant
Values: .default, .secondary, .muted, .tinted, .outline, .ghost, .destructive.
BubbleAlign
Values: .start, .end.
BubbleReactionsSide
Values: .top, .bottom.
BubbleGroup
Column that decides which bubbles show a tail.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
Bubble
One message, aligned to the start or end.
| Parameter | Type | Default |
|---|---|---|
variant | Variant: .default | .secondary | .muted | .tinted | .outline | .ghost | .destructive | .default |
align | Align: .start | .end | .start |
onLongPress | (() -> Void)? | nil |
content | () -> Content | - |
BubbleContent
The bubble itself, optionally pressable.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
action | () -> Void | - |
_ text | LocalizedStringKey | - |
verbatim | String | - |
Overloads: init(content:), init(action:content:), init(_:), init(verbatim:).
BubbleReactions
A small pill for reactions, overlapping the bubble's edge.
| Parameter | Type | Default |
|---|---|---|
side | BubbleReactionsSide: .top | .bottom | .bottom |
align | BubbleAlign: .start | .end | .end |
content | () -> Content | - |
_ text | LocalizedStringKey | - |
verbatim | String | - |
Overloads: init(side:align:content:), init(_:side:align:), init(verbatim:side:align:).
BubbleVariant
Values: Default, Secondary, Muted, Tinted, Outline, Ghost, Destructive.
BubbleAlign
Values: Start, End.
BubbleReactionsSide
Values: Top, Bottom.
BubbleGroup
Column that decides which bubbles show a tail.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable () -> Unit | - |
Bubble
One message, aligned to the start or end.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
variant | BubbleVariant: Default | Secondary | Muted | Tinted | Outline | Ghost | Destructive | BubbleVariant.Default |
align | BubbleAlign: Start | End | LocalBubbleAlign.current |
content | @Composable () -> Unit | - |
BubbleContent
The bubble itself, optionally pressable.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
onClick | (() -> Unit)? | null |
onLongPress | (() -> Unit)? | null |
content | @Composable () -> Unit | - |
text | String | - |
Overloads: BubbleContent(content), BubbleContent(text).
BubbleReactions
A small pill for reactions, overlapping the bubble's edge.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
side | BubbleReactionsSide: Top | Bottom | BubbleReactionsSide.Bottom |
align | BubbleAlign: Start | End | BubbleAlign.End |
content | @Composable RowScope.() -> Unit | - |
text | String | - |
Overloads: BubbleReactions(content), BubbleReactions(text).
