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

Message

Lays out a single chat message with an optional avatar, header and footer.

Message 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 { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Bubble, BubbleContent } from "@/components/ui/bubble"
import { Message, MessageAvatar, MessageContent } from "@/components/ui/message"

export default function MessageDemo() {
  return (
    <Message align="start" className="w-96">
      <MessageAvatar>
        <Avatar>
          <AvatarFallback>MK</AvatarFallback>
        </Avatar>
      </MessageAvatar>
      <MessageContent>
        <Bubble variant="muted">
          <BubbleContent>Are we still on for lunch tomorrow?</BubbleContent>
        </Bubble>

Message arranges one message row: an optional MessageAvatar and a MessageContent column. Inside the content, place an optional MessageHeader (such as a sender name), one or more bubbles, and an optional MessageFooter (such as a timestamp or read receipt). Wrap consecutive messages in MessageGroup to stack them.

Message handles layout only. Pair it with Bubble for the message surface and with Message Scroller for a scrolling transcript.

Installation

$ pnpm dlx shadcn@latest add @esuiss/message

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 message
  1. Add the cn helper.

  2. Copy and paste the following code into your project.

components/ui/message.tsx
import type * as React from "react"
import { cn } from "@/lib/utils"

function MessageGroup({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="message-group"
      className={cn("gap-2 flex min-w-0 flex-col", className)}
      {...props}
    />
  )
}

function Message({
  className,
  align = "start",
  1. Update the import paths to match your project setup.

Usage

import {
  Message,
  MessageAvatar,
  MessageContent,
  MessageFooter,
  MessageGroup,
  MessageHeader,
} from "@/components/ui/message"
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Bubble, BubbleContent } from "@/components/ui/bubble"
<div className="w-96">
  <Message align="start">
    <MessageAvatar>
      <Avatar>
        <AvatarFallback>MK</AvatarFallback>
      </Avatar>
    </MessageAvatar>
    <MessageContent>
      <Bubble variant="muted">
        <BubbleContent>Are we still on for lunch tomorrow?</BubbleContent>
      </Bubble>
    </MessageContent>
  </Message>
</div>

Composition

Use the following composition to build a Message:

Message
├── MessageAvatar
└── MessageContent
    ├── MessageHeader
    └── MessageFooter
MessageGroup
└── Message
    ├── MessageAvatar
    └── MessageContent
        └── MessageFooter

Examples

Align end

Set align="end" on Message for messages sent by the current user. The row reverses, so the avatar moves to the end.

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

export default function MessageAlignEnd() {
  return (
    <Message align="end" className="w-96">
      <MessageContent>
        <Bubble>
          <BubbleContent>Yes, see you at noon.</BubbleContent>
        </Bubble>
      </MessageContent>
    </Message>
  )
}

With header and footer

Put a MessageHeader above the bubble for the sender name and a MessageFooter below it for a timestamp. When a footer is present, the avatar shifts up to line up with the last bubble.

import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Bubble, BubbleContent } from "@/components/ui/bubble"
import {
  Message,
  MessageAvatar,
  MessageContent,
  MessageFooter,
  MessageHeader,
} from "@/components/ui/message"

export default function MessageWithHeaderAndFooter() {
  return (
    <Message align="start" className="w-96">
      <MessageAvatar>
        <Avatar>
          <AvatarFallback>JL</AvatarFallback>

Conversation

A MessageGroup with an incoming message of two bubbles and an outgoing reply.

import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Bubble, BubbleContent } from "@/components/ui/bubble"
import {
  Message,
  MessageAvatar,
  MessageContent,
  MessageFooter,
  MessageGroup,
} from "@/components/ui/message"

export default function MessageConversation() {
  return (
    <MessageGroup className="w-96 gap-4">
      <Message>
        <MessageAvatar>
          <Avatar>

API Reference

MessageGroup

Stacks several messages vertically.

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

Message

The row for one message that sets its alignment.

PropTypeDefault
align"start" | "end""start"

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

align="end" reverses the row for outgoing messages, so the avatar moves to the end and the content's children and the footer align to the end edge.

MessageAvatar

A round container for the sender's avatar, aligned to the bottom of the row.

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

MessageContent

The column that holds the header, bubbles and footer.

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

MessageHeader

Small secondary text above the bubbles, such as the sender name.

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

MessageFooter

Small secondary text below the bubbles, such as a timestamp.

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

The header and footer drop their horizontal padding when the message contains an element with data-variant="ghost".

Each part sets a data-slot, such as message or message-footer, for styling. Message also sets data-align.

Web

Web preview

import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Bubble, BubbleContent } from "@/components/ui/bubble"
import { Message, MessageAvatar, MessageContent } from "@/components/ui/message"

export default function MessageDemo() {
  return (
    <Message align="start">
      <MessageAvatar>
        <Avatar>
          <AvatarFallback>MK</AvatarFallback>
        </Avatar>
      </MessageAvatar>
      <MessageContent>
        <Bubble variant="muted">
          <BubbleContent>Are we still on for lunch tomorrow?</BubbleContent>
        </Bubble>
import SwiftUI

struct MessageExample: View {
  var body: some View {
    Message {
      MessageAvatar {
        Avatar { AvatarFallback("MK") }
      }
      MessageContent {
        Bubble(variant: .muted) {
          BubbleContent("Are we still on for lunch tomorrow?")
        }
      }
    }
  }
}
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.esuiss.ui.components.Avatar
import com.esuiss.ui.components.AvatarFallback
import com.esuiss.ui.components.Bubble
import com.esuiss.ui.components.BubbleContent
import com.esuiss.ui.components.BubbleVariant
import com.esuiss.ui.components.Message
import com.esuiss.ui.components.MessageAvatar
import com.esuiss.ui.components.MessageContent

@Composable
fun MessageInitials(text: String) {
    MessageAvatar {
        Avatar(fallback = { AvatarFallback(text) })

Message is a horizontal View that places an avatar next to a column of bubbles. Its align prop puts the row on the leading (start) or trailing (end) side and passes the alignment to any Bubble inside through context.

MessageGroup stacks several messages into a conversation. MessageHeader and MessageFooter hold small secondary text, such as a sender name or a timestamp. Put a MessageAvatar and a MessageContent inside each Message, and place Bubble components, a MessageHeader and a MessageFooter in MessageContent.

Installation

$ pnpm dlx shadcn@latest add @esuiss/message

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

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

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

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

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

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

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

  1. Install the following dependencies:
npx expo install cn
  1. Add the pieces it builds on: Bubble, Icon, Text.

  2. Copy and paste the following code into components/ui/message.tsx:

uniwind/components/ui/message.tsx
import { cn } from "cn"
import * as React from "react"
import { View, type ViewProps } from "react-native"
import { BubbleAlignContext, BubbleGroup } from "@/components/ui/bubble"
import { IconClassContext } from "@/components/ui/icon"
import { Text, TextClassContext } from "@/components/ui/text"

type MessageAlign = "start" | "end"

const MessageContext = React.createContext<{
  align: MessageAlign
  footer: boolean
}>({ align: "start", footer: false })

function wrapText(children: React.ReactNode) {
  const output: React.ReactNode[] = []
  1. Update the import paths to match your project setup.
  1. Install the following dependencies:
npx expo install cn
  1. Add the pieces it builds on: Bubble, Icon, Text.

  2. Copy and paste the following code into components/ui/message.tsx:

nativewind/components/ui/message.tsx
import { cn } from "cn"
import * as React from "react"
import { View, type ViewProps } from "react-native"
import { BubbleAlignContext, BubbleGroup } from "@/components/ui/bubble"
import { IconClassContext } from "@/components/ui/icon"
import { Text, TextClassContext } from "@/components/ui/text"

type MessageAlign = "start" | "end"

const MessageContext = React.createContext<{
  align: MessageAlign
  footer: boolean
}>({ align: "start", footer: false })

function wrapText(children: React.ReactNode) {
  const output: React.ReactNode[] = []
  1. Update the import paths to match your project setup.
  1. Add the pieces it builds on: Bubble, Icon, Text.

  2. Copy and paste the following code into components/ui/message.tsx:

stylesheet/components/ui/message.tsx
import * as React from "react"
import { StyleSheet, View, type ViewProps } from "react-native"
import { BubbleAlignContext, BubbleGroup } from "@/components/ui/bubble"
import { IconSizeContext } from "@/components/ui/icon"
import { Text, TextStyleContext } from "@/components/ui/text"
import { fontSize, radius, useTheme } from "@/components/ui/theme"

type MessageAlign = "start" | "end"

const MessageContext = React.createContext<{
  align: MessageAlign
  footer: boolean
}>({ align: "start", footer: false })

const styles = StyleSheet.create({
  group: { minWidth: 0, flexDirection: "column", gap: 8 },
  1. Update the import paths to match your project setup.
  1. Target iOS 17 or later.

  2. Add the Swift package to your app:

Package.swift
.package(url: "https://github.com/phosphor-icons/swift", from: "2.1.0")
  1. 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/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/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/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")
    implementation("com.adamglin:phosphor-icon-android:1.0.0")
}
  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/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/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/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/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/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 { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Bubble, BubbleContent } from "@/components/ui/bubble"
import { MessageGroup, Message, MessageAvatar, MessageContent, MessageHeader, MessageFooter } from "@/components/ui/message"
<Message align="start">
  <MessageAvatar>
    <Avatar>
      <AvatarFallback>MK</AvatarFallback>
    </Avatar>
  </MessageAvatar>
  <MessageContent>
    <Bubble variant="muted">
      <BubbleContent>Are we still on for lunch tomorrow?</BubbleContent>
    </Bubble>
  </MessageContent>
</Message>
import SwiftUI

struct MessageExample: View {
  var body: some View {
    Message {
      MessageAvatar {
        Avatar { AvatarFallback("MK") }
      }
      MessageContent {
        Bubble(variant: .muted) {
          BubbleContent("Are we still on for lunch tomorrow?")
        }
      }
    }
  }
}
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.esuiss.ui.components.Avatar
import com.esuiss.ui.components.AvatarFallback
import com.esuiss.ui.components.Bubble
import com.esuiss.ui.components.BubbleContent
import com.esuiss.ui.components.BubbleVariant
import com.esuiss.ui.components.Message
import com.esuiss.ui.components.MessageAvatar
import com.esuiss.ui.components.MessageContent

@Composable
fun MessageInitials(text: String) {
    MessageAvatar {
        Avatar(fallback = { AvatarFallback(text) })
    }
}

@Composable
fun MessageDefault() {
    Message(Modifier.fillMaxWidth()) {
        MessageInitials("MK")
        MessageContent {
            Bubble(variant = BubbleVariant.Muted) {
                BubbleContent("Are we still on for lunch tomorrow?")
            }
        }
    }
}

Examples

Align end

A message aligned to the trailing side, as for the current user.

Web

Web preview

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

export default function MessageAlignEnd() {
  return (
    <Message align="end">
      <MessageContent>
        <Bubble>
          <BubbleContent>Yes, see you at noon.</BubbleContent>
        </Bubble>
      </MessageContent>
    </Message>
  )
}
import SwiftUI

struct MessageAlignEndExample: View {
  var body: some View {
    Message(align: .end) {
      MessageContent {
        Bubble {
          BubbleContent("Yes, see you at noon.")
        }
      }
    }
  }
}
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.esuiss.ui.components.Bubble
import com.esuiss.ui.components.BubbleContent
import com.esuiss.ui.components.Message
import com.esuiss.ui.components.MessageAlign
import com.esuiss.ui.components.MessageContent

@Composable
fun MessageAlignEnd() {
    Message(Modifier.fillMaxWidth(), align = MessageAlign.End) {
        MessageContent {
            Bubble {
                BubbleContent("Yes, see you at noon.")
            }

With header and footer

A message with a sender name in MessageHeader and a timestamp in MessageFooter. When MessageContent contains a footer, the avatar shifts up to line up with the last bubble.

Web

Web preview

import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Bubble, BubbleContent } from "@/components/ui/bubble"
import {
  Message,
  MessageAvatar,
  MessageContent,
  MessageFooter,
  MessageHeader,
} from "@/components/ui/message"

export default function MessageWithHeaderAndFooter() {
  return (
    <Message align="start">
      <MessageAvatar>
        <Avatar>
          <AvatarFallback>JL</AvatarFallback>
import SwiftUI

struct MessageWithHeaderAndFooterExample: View {
  var body: some View {
    Message {
      MessageAvatar {
        Avatar { AvatarFallback("JL") }
      }
      MessageContent {
        MessageHeader(verbatim: "Jordan Lee")
        Bubble(variant: .muted) {
          BubbleContent("I pushed the updated designs to the shared folder.")
        }
        MessageFooter(verbatim: "9:41 AM")
      }
    }
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.esuiss.ui.components.Avatar
import com.esuiss.ui.components.AvatarFallback
import com.esuiss.ui.components.Bubble
import com.esuiss.ui.components.BubbleContent
import com.esuiss.ui.components.BubbleVariant
import com.esuiss.ui.components.Message
import com.esuiss.ui.components.MessageAvatar
import com.esuiss.ui.components.MessageContent
import com.esuiss.ui.components.MessageFooter
import com.esuiss.ui.components.MessageHeader

@Composable
fun MessageInitials(text: String) {

Conversation

A MessageGroup with an incoming and an outgoing message, including a read receipt footer.

Web

Web preview

import { ChecksIcon } from "phosphor-react-native"
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Bubble, BubbleContent } from "@/components/ui/bubble"
import { Icon } from "@/components/ui/icon"
import {
  Message,
  MessageAvatar,
  MessageContent,
  MessageFooter,
  MessageGroup,
} from "@/components/ui/message"
import { Text } from "@/components/ui/text"

export default function MessageConversation() {
  return (
    <MessageGroup className="gap-4">
import { ChecksIcon } from "phosphor-react-native"
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Bubble, BubbleContent } from "@/components/ui/bubble"
import { Icon } from "@/components/ui/icon"
import {
  Message,
  MessageAvatar,
  MessageContent,
  MessageFooter,
  MessageGroup,
} from "@/components/ui/message"
import { Text } from "@/components/ui/text"
import { useTheme } from "@/components/ui/theme"

export default function MessageConversation() {
  const { colors } = useTheme()
import PhosphorSwift
import SwiftUI

struct MessageConversationExample: View {
  var body: some View {
    MessageGroup(spacing: 16) {
      Message {
        MessageAvatar {
          Avatar { AvatarFallback("MK") }
        }
        MessageContent {
          Bubble(variant: .muted) {
            BubbleContent("Did the build pass?")
          }
          Bubble(variant: .muted) {
            BubbleContent("I want to ship before the weekend.")
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.Checks
import com.esuiss.ui.components.Avatar
import com.esuiss.ui.components.AvatarFallback
import com.esuiss.ui.components.Bubble
import com.esuiss.ui.components.BubbleContent
import com.esuiss.ui.components.BubbleVariant
import com.esuiss.ui.components.Icon
import com.esuiss.ui.components.Message

Accessibility

  • Messages are plain View and Text elements, so screen readers read the header, bubble text and footer in order.
  • Give avatars without visible text, such as images, an accessibilityLabel.

API Reference

MessageGroup

Vertical stack of messages.

Also accepts the props of ViewProps.

Message

Row that holds the avatar and content and sets the alignment.

PropTypeDefault
alignMessageAlign"start"

Also accepts the props of ViewProps.

align also passes the side to nested bubbles and the footer through context.

MessageAvatar

Round slot for an avatar, pinned to the bottom of the row.

Also accepts the props of ViewProps.

MessageContent

Column of bubbles built on BubbleGroup.

Also accepts the props of React.ComponentProps<typeof BubbleGroup>.

MessageHeader

Small secondary text above the bubbles.

Also accepts the props of ViewProps.

Plain strings in MessageHeader and MessageFooter are wrapped in Text for you, so you can pass text directly or mix it with an Icon.

MessageFooter

Small secondary text below the bubbles, aligned with the message side.

Also accepts the props of ViewProps.

MessageGroup

Vertical stack of messages.

ParameterTypeDefault
spacingCGFloat8
content() -> Content-

Message

Row that holds the avatar and content and sets the alignment.

ParameterTypeDefault
alignAlign.start
content() -> Content-

MessageAvatar

Round slot for an avatar, pinned to the bottom of the row.

ParameterTypeDefault
content() -> Content-

MessageContent

Column of bubbles built on BubbleGroup.

ParameterTypeDefault
content() -> Content-

MessageHeader

Small secondary text above the bubbles.

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

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

MessageFooter

Small secondary text below the bubbles, aligned with the message side.

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

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

MessageAlign

Values: Start, End.

MessageGroup

Vertical stack of messages.

ParameterTypeDefault
modifierModifierModifier
content@Composable ColumnScope.() -> Unit-

Message

Row that holds the avatar and content and sets the alignment.

ParameterTypeDefault
modifierModifierModifier
alignMessageAlign: Start | EndMessageAlign.Start
content@Composable () -> Unit-

MessageAvatar

Round slot for an avatar, pinned to the bottom of the row.

ParameterTypeDefault
modifierModifierModifier
content@Composable BoxScope.() -> Unit-

MessageContent

Column of bubbles built on BubbleGroup.

ParameterTypeDefault
modifierModifierModifier
content@Composable () -> Unit-

MessageHeader

Small secondary text above the bubbles.

ParameterTypeDefault
modifierModifierModifier
content@Composable RowScope.() -> Unit-
textString-

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

MessageFooter

Small secondary text below the bubbles, aligned with the message side.

ParameterTypeDefault
modifierModifierModifier
content@Composable RowScope.() -> Unit-
textString-

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

NextMessage ScrollerPreviousMenubar

On this page

  1. 01Installation
  2. 02Usage
  3. 03Composition
  4. 04Examples
    • Align end
    • With header and footer
    • Conversation
  5. 05API Reference
    • MessageGroup
    • Message
    • MessageAvatar
    • MessageContent
    • MessageHeader
    • MessageFooter
  6. 06Installation
  7. 07Usage
  8. 08Examples
    • Align end
    • With header and footer
    • Conversation
  9. 09Accessibility
  10. 10API Reference
    • MessageGroup
    • Message
    • MessageAvatar
    • MessageContent
    • MessageHeader
    • MessageFooter
    • MessageGroup
    • Message
    • MessageAvatar
    • MessageContent
    • MessageHeader
    • MessageFooter
    • MessageAlign
    • MessageGroup
    • Message
    • MessageAvatar
    • MessageContent
    • MessageHeader
    • MessageFooter