suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
  • AI
GitHubCreate
DocsComponentsPatternsInteractionsChartsBlocksAICreate
Components84
  • Overview
  • Accordion
  • Alert
  • Alert Dialog
  • Alert Sheet
  • Amount Input
  • Aspect Ratio
  • Attachment
  • Avatar
  • Badge
  • Bottom Bar
  • Breadcrumb
  • Bubble
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Chip
  • Code Block
  • Collapsible
  • Combobox
  • Command
  • Context Menu
  • Dialog
  • Direction
  • Drawer
  • Dropdown Menu
  • Empty
  • FAB
  • Field
  • Fullscreen Menu
  • Haptics
  • Header
  • Hover Card
  • Icon
  • Input
  • Input Accessory Bar
  • Input Group
  • Input OTP
  • Item
  • Kbd
  • Keyboard Scroll View
  • Keypad
  • Label
  • Marker
  • Menubar
  • Message
  • Message Scroller
  • Native Select
  • Navigation Menu
  • Page Indicator
  • Pagination
  • Pin Pad
  • Popover
  • Progress
  • QR Scanner
  • Questionnaire
  • Radio Group
  • Resizable
  • Screen
  • Scroll Area
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature Pad
  • Skeleton
  • Slider
  • Spinner
  • Switch
  • Tab Bar
  • Table
  • Tabs
  • Text
  • Textarea
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Trace
  • Wheel Picker
  • Widget

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.

import { Bubble, BubbleContent } from "@/components/ui/bubble"

export default function BubbleDemo() {
  return (
    <div className="flex w-96 flex-col">
      <Bubble align="start">
        <BubbleContent>Are we still on for lunch tomorrow?</BubbleContent>
      </Bubble>
    </div>
  )
}

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

$ pnpm dlx shadcn@latest add @esuiss/bubble

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add bubble
  1. Install the following dependencies and add the cn helper:
$ pnpm add @base-ui/react class-variance-authority
  1. Copy and paste the following code into your project.
components/ui/bubble.tsx
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import type * as React from "react"
import { cn } from "@/lib/utils"

function BubbleGroup({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="bubble-group"
      className={cn("gap-2 flex min-w-0 flex-col", className)}
      {...props}
    />
  )
}
  1. Update the import paths to match your project setup.

Usage

import {
  Bubble,
  BubbleContent,
  BubbleGroup,
  BubbleReactions,
} from "@/components/ui/bubble"
<div className="flex w-96 flex-col">
  <Bubble align="start">
    <BubbleContent>Are we still on for lunch tomorrow?</BubbleContent>
  </Bubble>
</div>

Composition

Use the following composition to build a Bubble:

Bubble
└── BubbleContent
BubbleGroup
└── Bubble
    ├── BubbleContent
    └── BubbleReactions

Examples

Variants

Use the variant prop to set the background and text color. This shows every variant, from default to destructive.

import { Bubble, BubbleContent, BubbleGroup } from "@/components/ui/bubble"

export default function BubbleVariants() {
  return (
    <BubbleGroup className="w-96">
      <Bubble align="start" variant="default">
        <BubbleContent>This is a default bubble.</BubbleContent>
      </Bubble>
      <Bubble align="start" variant="secondary">
        <BubbleContent>This is a secondary bubble.</BubbleContent>
      </Bubble>
      <Bubble align="start" variant="muted">
        <BubbleContent>This is a muted bubble.</BubbleContent>
      </Bubble>
      <Bubble align="start" variant="tinted">
        <BubbleContent>This is a tinted bubble.</BubbleContent>

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.

import { Bubble, BubbleContent, BubbleGroup } from "@/components/ui/bubble"

export default function BubbleConversation() {
  return (
    <BubbleGroup className="w-96">
      <Bubble variant="muted">
        <BubbleContent>
          Hey, did you get a chance to review the draft?
        </BubbleContent>
      </Bubble>
      <Bubble align="end">
        <BubbleContent>Yes, I left a few comments on the intro.</BubbleContent>
      </Bubble>
      <Bubble align="end">
        <BubbleContent>Everything else looks great.</BubbleContent>
      </Bubble>

With reactions

Pin reactions to different corners with the side and align props of BubbleReactions. They default to the bottom-end corner.

import {
  Bubble,
  BubbleContent,
  BubbleGroup,
  BubbleReactions,
} from "@/components/ui/bubble"

export default function BubbleWithReactions() {
  return (
    <BubbleGroup className="w-96">
      <Bubble align="start" variant="muted">
        <BubbleContent>We just hit 10,000 users!</BubbleContent>
        <BubbleReactions>🎉 3</BubbleReactions>
      </Bubble>
      <Bubble align="end">
        <BubbleContent>That is amazing news.</BubbleContent>

Interactive

Render BubbleContent as a button or a for tappable bubbles, such as suggested replies; these get hover and focus styles.

import { Bubble, BubbleContent } from "@/components/ui/bubble"

export default function BubbleInteractive() {
  return (
    <div className="flex w-96 flex-col">
      <Bubble variant="outline" align="start">
        <BubbleContent render={<button type="button" />}>
          Show me the latest release notes
        </BubbleContent>
      </Bubble>
    </div>
  )
}

Accessibility

  • Bubbles are static content by default and contribute no focusable elements.
  • When BubbleContent renders a button or a, 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.

PropTypeDefault
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">.

PropTypeDefault
asChildbooleanfalse

Also accepts the props of React.ComponentProps<"div">.

PropTypeDefault
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.

PropTypeDefault
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

Web preview

import { Bubble, BubbleContent } from "@/components/ui/bubble"

export default function BubbleDemo() {
  return (
    <Bubble align="start">
      <BubbleContent>Are we still on for lunch tomorrow?</BubbleContent>
    </Bubble>
  )
}
import SwiftUI

struct BubbleExample: View {
  var body: some View {
    Bubble {
      BubbleContent("Are we still on for lunch tomorrow?")
    }
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.components.Bubble
import com.esuiss.ui.components.BubbleContent

@Composable
fun BubbleDefault() {
    Bubble {
        BubbleContent("Are we still on for lunch tomorrow?")
    }
}

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

$ pnpm dlx shadcn@latest add @esuiss/bubble

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add bubble
$ pnpm dlx shadcn@latest add @esuiss/bubble

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add bubble --platform swift
$ pnpm dlx shadcn@latest add @esuiss/bubble

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add bubble --platform kotlin

The CLI also adds what it builds on: Icon, Text.

  1. Install the following dependencies:
npx expo install cn phosphor-react-native react-native-svg
  1. Add the pieces it builds on: Icon, Text.

  2. Copy the primitives it uses into components/primitives:

uniwind/components/primitives/hooks.ts
import * as React from "react"
import { BackHandler } from "react-native"

function useEffectEvent<TArgs extends readonly unknown[], TResult>(
  callback: (...args: TArgs) => TResult
): (...args: TArgs) => TResult {
  const callbackRef = React.useRef(callback)

  React.useLayoutEffect(() => {
    callbackRef.current = callback
  })

  return React.useCallback(
    (...args: TArgs): TResult => callbackRef.current(...args),
    []
  )
uniwind/components/primitives/merge-props.ts
type AnyProps = Record<string, unknown>

type PropsGetter = (previous: AnyProps) => object

type MergePropsInput = object | PropsGetter | null | undefined

type Handler = (...args: unknown[]) => unknown

type StyleCallback = (state: never) => unknown

const EMPTY_PROPS: AnyProps = {}

function isEventHandler(key: string, value: unknown) {
  const code0 = key.charCodeAt(0)
  const code1 = key.charCodeAt(1)
  const code2 = key.charCodeAt(2)
uniwind/components/primitives/types.ts
import type * as React from "react"
import type {
  GestureResponderEvent,
  HostInstance,
  NativeSyntheticEvent,
  StyleProp,
  ViewStyle,
} from "react-native"

type Side = "top" | "bottom" | "left" | "right"
type Align = "start" | "center" | "end"
type Orientation = "horizontal" | "vertical"

type ComponentRenderFn<Props, State> = (
  props: Props,
  state: State
uniwind/components/primitives/use-render.tsx
import * as React from "react"
import { useComposedRefs } from "./hooks"
import { mergeClassNames, mergeProps, mergeStyles } from "./merge-props"
import type { ClassNameProp, RenderProp, StyleValue } from "./types"

type AnyProps = Record<string, unknown>

type RefInput<T> = React.Ref<T> | undefined

interface UseRenderParameters<State, RefType = unknown, Props = AnyProps> {
  defaultComponent?: React.ElementType | undefined
  render?: RenderProp<Props, State> | undefined
  props?: object | readonly (object | null | undefined)[] | undefined
  state?: State | undefined
  ref?: RefInput<RefType> | readonly RefInput<RefType>[] | undefined
  className?: ClassNameProp<State>
  1. Copy and paste the following code into components/ui/bubble.tsx:
uniwind/components/ui/bubble.tsx
import { cn } from "cn"
import type { IconProps as PhosphorIconProps } from "phosphor-react-native"
import * as React from "react"
import {
  type GestureResponderEvent,
  I18nManager,
  Pressable,
  View,
  type ViewProps,
} from "react-native"
import Svg, { Path } from "react-native-svg"
import type { RenderProp } from "@/components/primitives/types"
import { useRender } from "@/components/primitives/use-render"
import { Icon, IconClassContext } from "@/components/ui/icon"
import { Text, TextClassContext } from "@/components/ui/text"
  1. Update the import paths to match your project setup.
  1. Install the following dependencies:
npx expo install cn phosphor-react-native react-native-svg
  1. Add the pieces it builds on: Icon, Text.

  2. Copy the primitives it uses into components/primitives:

nativewind/components/primitives/hooks.ts
import * as React from "react"
import { BackHandler } from "react-native"

function useEffectEvent<TArgs extends readonly unknown[], TResult>(
  callback: (...args: TArgs) => TResult
): (...args: TArgs) => TResult {
  const callbackRef = React.useRef(callback)

  React.useLayoutEffect(() => {
    callbackRef.current = callback
  })

  return React.useCallback(
    (...args: TArgs): TResult => callbackRef.current(...args),
    []
  )
nativewind/components/primitives/merge-props.ts
type AnyProps = Record<string, unknown>

type PropsGetter = (previous: AnyProps) => object

type MergePropsInput = object | PropsGetter | null | undefined

type Handler = (...args: unknown[]) => unknown

type StyleCallback = (state: never) => unknown

const EMPTY_PROPS: AnyProps = {}

function isEventHandler(key: string, value: unknown) {
  const code0 = key.charCodeAt(0)
  const code1 = key.charCodeAt(1)
  const code2 = key.charCodeAt(2)
nativewind/components/primitives/types.ts
import type * as React from "react"
import type {
  GestureResponderEvent,
  HostInstance,
  NativeSyntheticEvent,
  StyleProp,
  ViewStyle,
} from "react-native"

type Side = "top" | "bottom" | "left" | "right"
type Align = "start" | "center" | "end"
type Orientation = "horizontal" | "vertical"

type ComponentRenderFn<Props, State> = (
  props: Props,
  state: State
nativewind/components/primitives/use-render.tsx
import * as React from "react"
import { useComposedRefs } from "./hooks"
import { mergeClassNames, mergeProps, mergeStyles } from "./merge-props"
import type { ClassNameProp, RenderProp, StyleValue } from "./types"

type AnyProps = Record<string, unknown>

type RefInput<T> = React.Ref<T> | undefined

interface UseRenderParameters<State, RefType = unknown, Props = AnyProps> {
  defaultComponent?: React.ElementType | undefined
  render?: RenderProp<Props, State> | undefined
  props?: object | readonly (object | null | undefined)[] | undefined
  state?: State | undefined
  ref?: RefInput<RefType> | readonly RefInput<RefType>[] | undefined
  className?: ClassNameProp<State>
  1. Copy and paste the following code into components/ui/bubble.tsx:
nativewind/components/ui/bubble.tsx
import { cn } from "cn"
import type { IconProps as PhosphorIconProps } from "phosphor-react-native"
import * as React from "react"
import {
  type GestureResponderEvent,
  I18nManager,
  Pressable,
  View,
  type ViewProps,
} from "react-native"
import Svg, { Path } from "react-native-svg"
import type { RenderProp } from "@/components/primitives/types"
import { useRender } from "@/components/primitives/use-render"
import { Icon, IconClassContext } from "@/components/ui/icon"
import { Text, TextClassContext } from "@/components/ui/text"
  1. Update the import paths to match your project setup.
  1. Install the following dependencies:
npx expo install phosphor-react-native react-native-svg
  1. Add the pieces it builds on: Icon, Text.

  2. Copy the primitives it uses into components/primitives:

stylesheet/components/primitives/hooks.ts
import * as React from "react"
import { BackHandler } from "react-native"

function useEffectEvent<TArgs extends readonly unknown[], TResult>(
  callback: (...args: TArgs) => TResult
): (...args: TArgs) => TResult {
  const callbackRef = React.useRef(callback)

  React.useLayoutEffect(() => {
    callbackRef.current = callback
  })

  return React.useCallback(
    (...args: TArgs): TResult => callbackRef.current(...args),
    []
  )
stylesheet/components/primitives/merge-props.ts
type AnyProps = Record<string, unknown>

type PropsGetter = (previous: AnyProps) => object

type MergePropsInput = object | PropsGetter | null | undefined

type Handler = (...args: unknown[]) => unknown

type StyleCallback = (state: never) => unknown

const EMPTY_PROPS: AnyProps = {}

function isEventHandler(key: string, value: unknown) {
  const code0 = key.charCodeAt(0)
  const code1 = key.charCodeAt(1)
  const code2 = key.charCodeAt(2)
stylesheet/components/primitives/types.ts
import type * as React from "react"
import type {
  GestureResponderEvent,
  HostInstance,
  NativeSyntheticEvent,
  StyleProp,
  ViewStyle,
} from "react-native"

type Side = "top" | "bottom" | "left" | "right"
type Align = "start" | "center" | "end"
type Orientation = "horizontal" | "vertical"

type ComponentRenderFn<Props, State> = (
  props: Props,
  state: State
stylesheet/components/primitives/use-render.tsx
import * as React from "react"
import { useComposedRefs } from "./hooks"
import { mergeClassNames, mergeProps, mergeStyles } from "./merge-props"
import type { ClassNameProp, RenderProp, StyleValue } from "./types"

type AnyProps = Record<string, unknown>

type RefInput<T> = React.Ref<T> | undefined

interface UseRenderParameters<State, RefType = unknown, Props = AnyProps> {
  defaultComponent?: React.ElementType | undefined
  render?: RenderProp<Props, State> | undefined
  props?: object | readonly (object | null | undefined)[] | undefined
  state?: State | undefined
  ref?: RefInput<RefType> | readonly RefInput<RefType>[] | undefined
  className?: ClassNameProp<State>
  1. Copy and paste the following code into components/ui/bubble.tsx:
stylesheet/components/ui/bubble.tsx
import type { IconProps as PhosphorIconProps } from "phosphor-react-native"
import * as React from "react"
import {
  type GestureResponderEvent,
  I18nManager,
  Pressable,
  type StyleProp,
  StyleSheet,
  View,
  type ViewProps,
  type ViewStyle,
} from "react-native"
import Svg, { Path } from "react-native-svg"
import type { RenderProp } from "@/components/primitives/types"
import { useRender } from "@/components/primitives/use-render"
import { Icon } from "@/components/ui/icon"
  1. Update the import paths to match your project setup.
  1. Target iOS 17 or later.

  2. Copy the theme files every view uses:

swift/Theme/Theme.swift
import CoreText
import SwiftUI
import UIKit

struct RGBA: Sendable {
  let red: CGFloat
  let green: CGFloat
  let blue: CGFloat
  let alpha: CGFloat

  init(_ hex: UInt32, _ alpha: CGFloat = 1) {
    red = CGFloat((hex >> 16) & 0xFF) / 255
    green = CGFloat((hex >> 8) & 0xFF) / 255
    blue = CGFloat(hex & 0xFF) / 255
    self.alpha = alpha
  }
swift/Theme/Tokens.swift
import SwiftUI

public enum EsuissColor {
  public static let background = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x000000))
  public static let foreground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let card = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let cardForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let popover = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let popoverForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let primary = Color.adaptive(light: .init(0x0071E3), dark: .init(0x0A84FF))
  public static let primaryForeground = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0xFFFFFF))
  public static let secondary = Color.adaptive(light: .init(0x000000, 0.04), dark: .init(0xFFFFFF, 0.1))
  public static let secondaryForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let muted = Color.adaptive(light: .init(0xF5F5F7), dark: .init(0x161617))
  public static let mutedForeground = Color.adaptive(light: .init(0x6E6E73), dark: .init(0x86868B))
  public static let accent = Color.adaptive(light: .init(0x000000, 0.06), dark: .init(0xFFFFFF, 0.1))
  1. Copy the source and every file it uses:
swift/Components/Bubble.swift
import SwiftUI

public enum BubbleVariant: CaseIterable, Sendable {
  case `default`, secondary, muted, tinted, outline, ghost, destructive

  var hasTail: Bool {
    self != .ghost && self != .outline
  }
}

public enum BubbleAlign: CaseIterable, Sendable {
  case start, end
}

public enum BubbleReactionsSide: CaseIterable, Sendable {
  case top, bottom
swift/Components/KeyboardScrollView.swift
import SwiftUI
import UIKit

public struct KeyboardScrollView<Content: View>: View {
  let showsIndicators: Bool
  let content: Content

  public init(showsIndicators: Bool = true, @ViewBuilder content: () -> Content) {
    self.showsIndicators = showsIndicators
    self.content = content()
  }

  public var body: some View {
    ScrollView(.vertical, showsIndicators: showsIndicators) {
      content
        .frame(maxWidth: .infinity, alignment: .topLeading)
swift/Components/Message.swift
import SwiftUI

public typealias MessageAlign = BubbleAlign

struct MessageGhostKey: PreferenceKey {
  static let defaultValue = false

  static func reduce(value: inout Bool, nextValue: () -> Bool) {
    value = value || nextValue()
  }
}

struct MessageFooterKey: PreferenceKey {
  static let defaultValue: CGFloat = 0

  static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
swift/Components/Screen.swift
import SwiftUI

extension EnvironmentValues {
  @Entry var screenBackground: Color = EsuissColor.background
}

public struct Screen<Content: View>: View {
  public enum Background: CaseIterable, Sendable {
    case background, muted

    var color: Color {
      switch self {
      case .background: EsuissColor.background
      case .muted: EsuissColor.muted
      }
    }
  1. Add the files to your app target.
  1. Apply the Compose compiler plugin, enable Compose, set compileSdk to 37 or higher and minSdk to 24 or higher, and add the dependencies:
build.gradle.kts
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
}
  1. Copy the theme files every view uses:
kotlin/theme/Theme.kt
package com.esuiss.ui.theme

import android.content.res.AssetManager
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.dropShadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.shadow.Shadow as DropShadow
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
kotlin/theme/Tokens.kt
package com.esuiss.ui.theme

import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp

@Immutable
data class Colors(
    val background: Color,
    val foreground: Color,
    val card: Color,
    val cardForeground: Color,
    val popover: Color,
    val popoverForeground: Color,
    val primary: Color,
  1. Copy the source and every file it uses:
kotlin/components/Bubble.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
kotlin/components/Avatar.kt
package com.esuiss.ui.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
kotlin/components/Button.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
kotlin/components/ButtonGroup.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.Immutable
kotlin/components/Content.kt
package com.esuiss.ui.components

import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

val LocalContentStyle = compositionLocalOf { TextStyle.Default }

val LocalContentColor = compositionLocalOf { Color.Unspecified }

val LocalIconSize = compositionLocalOf { 20.dp }
kotlin/components/Haptics.kt
package com.esuiss.ui.components

import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.hapticfeedback.HapticFeedback
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalHapticFeedback

val LocalHapticsEnabled = staticCompositionLocalOf { true }

@Composable
fun ProvideHaptics(enabled: Boolean, content: @Composable () -> Unit) {
    CompositionLocalProvider(LocalHapticsEnabled provides enabled, content = content)
}
kotlin/components/Icon.kt
package com.esuiss.ui.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.Dp
import com.esuiss.ui.theme.EsuissTheme

@Composable
fun Icon(
    imageVector: ImageVector,
kotlin/components/Message.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
kotlin/components/SignaturePad.kt
package com.esuiss.ui.components

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.getValue
  1. Update the com.esuiss.ui package names to match your project.

Usage

import { BubbleGroup, Bubble, BubbleContent, BubbleReactions } from "@/components/ui/bubble"
<Bubble align="start">
  <BubbleContent>Are we still on for lunch tomorrow?</BubbleContent>
</Bubble>
import SwiftUI

struct BubbleExample: View {
  var body: some View {
    Bubble {
      BubbleContent("Are we still on for lunch tomorrow?")
    }
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.components.Bubble
import com.esuiss.ui.components.BubbleContent

@Composable
fun BubbleDefault() {
    Bubble {
        BubbleContent("Are we still on for lunch tomorrow?")
    }
}

Examples

Variants

All seven variants.

Use the variant prop to set the colors.

Web

Web preview

import { Bubble, BubbleContent, BubbleGroup } from "@/components/ui/bubble"

const VARIANTS = [
  "default",
  "secondary",
  "muted",
  "tinted",
  "outline",
  "ghost",
  "destructive",
] as const

export default function BubbleVariants() {
  return (
    <BubbleGroup>
      {VARIANTS.map((variant) => (
import SwiftUI

struct BubbleVariantsExample: View {
  var body: some View {
    BubbleGroup {
      ForEach(BubbleVariantSample.all, id: \.name) { sample in
        Bubble(variant: sample.variant) {
          BubbleContent(verbatim: "This is a \(sample.name) bubble.")
        }
      }
    }
  }
}

struct BubbleVariantSample {
  let variant: BubbleVariant
import androidx.compose.runtime.Composable
import com.esuiss.ui.components.Bubble
import com.esuiss.ui.components.BubbleContent
import com.esuiss.ui.components.BubbleGroup
import com.esuiss.ui.components.BubbleVariant

@Composable
fun BubbleVariants() {
    BubbleGroup {
        BubbleVariant.entries.forEach { variant ->
            Bubble(variant = variant) {
                BubbleContent("This is a ${variant.name.lowercase()} bubble.")
            }
        }
    }
}

Conversation

A BubbleGroup with messages from both sides and merged tails.

Set align="end" for messages from the current user.

Web

Web preview

import { Bubble, BubbleContent, BubbleGroup } from "@/components/ui/bubble"

export default function BubbleConversation() {
  return (
    <BubbleGroup>
      <Bubble variant="muted">
        <BubbleContent>
          Hey, did you get a chance to review the draft?
        </BubbleContent>
      </Bubble>
      <Bubble align="end">
        <BubbleContent>Yes, I left a few comments on the intro.</BubbleContent>
      </Bubble>
      <Bubble align="end">
        <BubbleContent>Everything else looks great.</BubbleContent>
      </Bubble>
import SwiftUI

struct BubbleConversationExample: View {
  var body: some View {
    BubbleGroup {
      Bubble(variant: .muted) {
        BubbleContent("Hey, did you get a chance to review the draft?")
      }
      Bubble(align: .end) {
        BubbleContent("Yes, I left a few comments on the intro.")
      }
      Bubble(align: .end) {
        BubbleContent("Everything else looks great.")
      }
      Bubble(variant: .muted) {
        BubbleContent("Thanks! I will update it this afternoon.")
import androidx.compose.runtime.Composable
import com.esuiss.ui.components.Bubble
import com.esuiss.ui.components.BubbleAlign
import com.esuiss.ui.components.BubbleContent
import com.esuiss.ui.components.BubbleGroup
import com.esuiss.ui.components.BubbleVariant

@Composable
fun BubbleConversation() {
    BubbleGroup {
        Bubble(variant = BubbleVariant.Muted) {
            BubbleContent("Hey, did you get a chance to review the draft?")
        }
        Bubble(align = BubbleAlign.End) {
            BubbleContent("Yes, I left a few comments on the intro.")
        }

With reactions

Reaction pills on the bottom and top edges, placed with the side and align props of BubbleReactions.

Web

Web preview

import {
  Bubble,
  BubbleContent,
  BubbleGroup,
  BubbleReactions,
} from "@/components/ui/bubble"

export default function BubbleWithReactions() {
  return (
    <BubbleGroup>
      <Bubble align="start" variant="muted">
        <BubbleContent>We just hit 10,000 users!</BubbleContent>
        <BubbleReactions>🎉 3</BubbleReactions>
      </Bubble>
      <Bubble align="end">
        <BubbleContent>That is amazing news.</BubbleContent>
import SwiftUI

struct BubbleWithReactionsExample: View {
  var body: some View {
    BubbleGroup {
      Bubble(variant: .muted) {
        BubbleContent("We just hit 10,000 users!")
        BubbleReactions(verbatim: "🎉 3")
      }
      Bubble(align: .end) {
        BubbleContent("That is amazing news.")
        BubbleReactions(verbatim: "❤️", align: .start)
      }
      Bubble(variant: .secondary) {
        BubbleContent("Reactions can sit on top as well.")
        BubbleReactions(verbatim: "👍 2", side: .top)
import androidx.compose.runtime.Composable
import com.esuiss.ui.components.Bubble
import com.esuiss.ui.components.BubbleAlign
import com.esuiss.ui.components.BubbleContent
import com.esuiss.ui.components.BubbleGroup
import com.esuiss.ui.components.BubbleReactions
import com.esuiss.ui.components.BubbleReactionsSide
import com.esuiss.ui.components.BubbleVariant

@Composable
fun BubbleWithReactions() {
    BubbleGroup {
        Bubble(variant = BubbleVariant.Muted) {
            BubbleContent("We just hit 10,000 users!")
            BubbleReactions("🎉 3")
        }

Interactive

A pressable outline bubble with onPress.

A pressable outline bubble with onClick.

Web

Web preview

import { Bubble, BubbleContent } from "@/components/ui/bubble"

export default function BubbleInteractive() {
  return (
    <Bubble variant="outline" align="start">
      <BubbleContent onPress={() => undefined}>
        Show me the latest release notes
      </BubbleContent>
    </Bubble>
  )
}
import SwiftUI

struct BubbleInteractiveExample: View {
  var body: some View {
    Bubble(variant: .outline) {
      BubbleContent(action: {}) {
        Text("Show me the latest release notes")
      }
    }
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.components.Bubble
import com.esuiss.ui.components.BubbleContent
import com.esuiss.ui.components.BubbleVariant

@Composable
fun BubbleInteractive() {
    Bubble(variant = BubbleVariant.Outline) {
        BubbleContent("Show me the latest release notes", onClick = {})
    }
}

Long press actions

A bubble that opens a context menu on long press.

Use render on BubbleContent to attach it to the trigger.

React Native
Bubble long press actions in React Native, light modeBubble long press actions in React Native, dark mode
import { View } from "react-native"
import {
  ContextActions,
  ContextActionsContent,
  ContextActionsItem,
  ContextActionsTrigger,
} from "@/components/patterns/context-actions"
import { Bubble, BubbleContent } from "@/components/ui/bubble"

export default function BubbleLongPressActions() {
  return (
    <View>
      <ContextActions>
        <Bubble variant="muted">
          <BubbleContent
            accessibilityLabel="Message from Maya"
import SwiftUI

struct BubbleLongPressActionsExample: View {
  var body: some View {
    Bubble(variant: .muted) {
      BubbleContent("Hold this message to see its actions.")
        .accessibilityLabel(Text("Message from Maya"))
        .contextActions {
          ContextActionsItem("Reply") {}
          ContextActionsItem("Copy") {}
          ContextActionsItem("Delete", variant: .destructive) {}
        }
    }
  }
}
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import com.esuiss.ui.components.Bubble
import com.esuiss.ui.components.BubbleContent
import com.esuiss.ui.components.BubbleVariant
import com.esuiss.ui.components.MenuItemVariant
import com.esuiss.ui.patterns.ContextActions
import com.esuiss.ui.patterns.ContextActionsContent
import com.esuiss.ui.patterns.ContextActionsItem
import com.esuiss.ui.patterns.ContextActionsTrigger

@Composable
fun BubbleLongPressActions() {

Accessibility

  • BubbleContent gets the button role when it has onPress or onLongPress.
  • The tail is hidden from VoiceOver and TalkBack.
  • Give long-press bubbles an accessibilityLabel that 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.

PropTypeDefault
variantBubbleVariant"default"
alignBubbleAlign-

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.

PropTypeDefault
renderRenderProp<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.

PropTypeDefault
alignBubbleAlign"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.

ParameterTypeDefault
content() -> Content-

Bubble

One message, aligned to the start or end.

ParameterTypeDefault
variantVariant: .default | .secondary | .muted | .tinted | .outline | .ghost | .destructive.default
alignAlign: .start | .end.start
onLongPress(() -> Void)?nil
content() -> Content-

BubbleContent

The bubble itself, optionally pressable.

ParameterTypeDefault
content() -> Content-
action() -> Void-
_ textLocalizedStringKey-
verbatimString-

Overloads: init(content:), init(action:content:), init(_:), init(verbatim:).

BubbleReactions

A small pill for reactions, overlapping the bubble's edge.

ParameterTypeDefault
sideBubbleReactionsSide: .top | .bottom.bottom
alignBubbleAlign: .start | .end.end
content() -> Content-
_ textLocalizedStringKey-
verbatimString-

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.

ParameterTypeDefault
modifierModifierModifier
content@Composable () -> Unit-

Bubble

One message, aligned to the start or end.

ParameterTypeDefault
modifierModifierModifier
variantBubbleVariant: Default | Secondary | Muted | Tinted | Outline | Ghost | DestructiveBubbleVariant.Default
alignBubbleAlign: Start | EndLocalBubbleAlign.current
content@Composable () -> Unit-

BubbleContent

The bubble itself, optionally pressable.

ParameterTypeDefault
modifierModifierModifier
onClick(() -> Unit)?null
onLongPress(() -> Unit)?null
content@Composable () -> Unit-
textString-

Overloads: BubbleContent(content), BubbleContent(text).

BubbleReactions

A small pill for reactions, overlapping the bubble's edge.

ParameterTypeDefault
modifierModifierModifier
sideBubbleReactionsSide: Top | BottomBubbleReactionsSide.Bottom
alignBubbleAlign: Start | EndBubbleAlign.End
content@Composable RowScope.() -> Unit-
textString-

Overloads: BubbleReactions(content), BubbleReactions(text).

NextButtonPreviousBreadcrumb

On this page

  1. 01Installation
  2. 02Usage
  3. 03Composition
  4. 04Examples
    • Variants
    • Conversation
    • With reactions
    • Interactive
  5. 05Accessibility
  6. 06API Reference
    • BubbleGroup
    • Bubble
    • BubbleContent
    • BubbleReactions
  7. 07Installation
  8. 08Usage
  9. 09Examples
    • Variants
    • Conversation
    • With reactions
    • Interactive
    • Long press actions
  10. 10Accessibility
  11. 11API Reference
    • BubbleGroup
    • Bubble
    • BubbleContent
    • BubbleReactions
    • BubbleVariant
    • BubbleAlign
    • BubbleReactionsSide
    • BubbleGroup
    • Bubble
    • BubbleContent
    • BubbleReactions
    • BubbleVariant
    • BubbleAlign
    • BubbleReactionsSide
    • BubbleGroup
    • Bubble
    • BubbleContent
    • BubbleReactions