suiss/uim · React Native Component
Message
A chat message row that lays out an avatar, a group of bubbles, and an optional header and footer.
Message is an open-source mobile component from suiss/uim for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim 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 function MessageExample() {
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>
</MessageContent>
</Message>
)
}import EsuissUI
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?")
}
}
}
}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.
Installation
$ pnpm dlx @esuiss/uim@latest add message$ pnpm dlx @esuiss/uim@latest add message --platform swift$ pnpm dlx @esuiss/uim@latest add message --platform kotlinThe CLI also adds what it builds on: Bubble, Icon, Text.
Manual
- Install the dependencies:
npx expo install cnimport { 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[] = []- Update the import paths to match your project.
- Install the dependencies:
npx expo install cnimport { 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[] = []- Update the import paths to match your project.
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 },- Update the import paths to match your project.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
.package(url: "https://github.com/phosphor-icons/swift", from: "2.1.0")- Copy the theme files every view uses:
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
}import SwiftUI
extension Color {
public static let surface = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x000000))
public static let surfaceSecondary = Color.adaptive(light: .init(0xF5F5F7), dark: .init(0x161617))
public static let surfaceTertiary = Color.adaptive(light: .init(0xE8E8ED), dark: .init(0x2C2C2E))
public static let surfaceRaised = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
public static let label = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
public static let labelSecondary = Color.adaptive(light: .init(0x6E6E73), dark: .init(0xA1A1A6))
public static let labelTertiary = Color.adaptive(light: .init(0x86868B), dark: .init(0x86868B))
public static let labelQuaternary = Color.adaptive(light: .init(0xD2D2D7), dark: .init(0x424245))
public static let control = Color.adaptive(light: .init(0x000000, 0.04), dark: .init(0xFFFFFF, 0.1))
public static let controlPressed = Color.adaptive(light: .init(0x000000, 0.12), dark: .init(0xFFFFFF, 0.22))
public static let controlSelected = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
public static let controlDisabled = Color.adaptive(light: .init(0x000000, 0.03), dark: .init(0xFFFFFF, 0.05))
public static let onControlSelected = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x000000))- Copy the source and every file it uses:
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) {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, bottomimport PhosphorSwift
import SwiftUI
extension Shadow {
static let control = Shadow(color: .black.opacity(0.08), radius: 0.5, y: 0.5)
static let thumb = Shadow(color: .black.opacity(0.12), radius: 1.5, y: 1)
}
struct SelectionIndicator<Mark: View>: View {
let checked: Bool
let pressed: Bool
let cornerRadius: CGFloat
let mark: Mark
@Environment(\.isEnabled) private var isEnabled
@Environment(\.isInvalid) private var invalidimport SwiftUI
extension EnvironmentValues {
@Entry public var isInvalid = false
@Entry var fieldInset = false
@Entry var fieldGroupInset = false
@Entry var fieldSetInset = false
}
extension View {
public func invalid(_ isInvalid: Bool = true) -> some View {
environment(\.isInvalid, isInvalid)
}
}
public enum FieldOrientation: CaseIterable, Sendable {import SwiftUI
extension EnvironmentValues {
@Entry public var hapticsEnabled = true
}
extension View {
public func haptics(_ enabled: Bool) -> some View {
environment(\.hapticsEnabled, enabled)
}
func hapticFeedback<Trigger: Equatable>(_ feedback: SensoryFeedback, trigger: Trigger) -> some View {
modifier(HapticFeedbackModifier(feedback: feedback, trigger: trigger) { _, _ in true })
}
func hapticFeedback<Trigger: Equatable>(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)import SwiftUI
extension EnvironmentValues {
@Entry var screenBackground: Color = .surface
}
public struct Screen<Content: View>: View {
public enum Background: CaseIterable, Sendable {
case surface, surfaceSecondary
var color: Color {
switch self {
case .surface: .surface
case .surfaceSecondary: .surfaceSecondary
}
}import SwiftUI
public struct Separator: View {
let orientation: Axis
public init(_ orientation: Axis = .horizontal) {
self.orientation = orientation
}
public var body: some View {
Rectangle()
.fill(Color.separator)
.frame(width: orientation == .vertical ? 1 : nil, height: orientation == .horizontal ? 1 : nil)
.frame(maxWidth: orientation == .horizontal ? .infinity : nil, maxHeight: orientation == .vertical ? .infinity : nil)
.accessibilityHidden(true)
}import SwiftUI
public enum TextVariant: CaseIterable, Sendable {
case `default`, h1, h2, h3, h4, p, blockquote, code, lead, large, small, muted
var style: TextStyle {
switch self {
case .h1: .xl3
case .h2: .xl2
case .h3: .xl
case .h4, .lead, .large: .lg
case .code, .small, .muted: .sm
default: .base
}
}- Add the files to your app target.
- Set
minSdkto 24 or higher and add the dependencies:
implementation(platform("androidx.compose:compose-bom:2026.09.00"))
implementation("androidx.compose.foundation:foundation")
implementation("androidx.compose.ui:ui")- Copy the theme files every view uses:
package com.esuiss.ui.theme
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.text.TextStyle
import androidx.compose.ui.text.style.LineHeightStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.DpOffsetpackage com.esuiss.ui.theme
import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
@Immutable
data class Colors(
val surface: Color,
val surfaceSecondary: Color,
val surfaceTertiary: Color,
val surfaceRaised: Color,
val label: Color,
val labelSecondary: Color,
val labelTertiary: Color,
val labelQuaternary: Color,- Copy the source and every file it uses:
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.Composablepackage 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.Modifierpackage 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.BasicTextpackage 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.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShapepackage 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.Immutablepackage 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 }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)
}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,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- Update the
com.esuiss.uipackage names to match your project.
Usage
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>Put a MessageAvatar and a MessageContent inside each Message, and place Bubble components, a MessageHeader and a MessageFooter in MessageContent.
Plain strings in MessageHeader and MessageFooter are wrapped in Text for you, so you can pass text directly or mix it with an Icon.
When MessageContent contains a MessageFooter, the avatar shifts up so it lines up with the last bubble instead of the footer.
Examples
Align end
A message aligned to the trailing side, as for the current user.


import { Bubble, BubbleContent } from "@/components/ui/bubble"
import { Message, MessageContent } from "@/components/ui/message"
export function MessageAlignEndExample() {
return (
<Message align="end">
<MessageContent>
<Bubble>
<BubbleContent>Yes, see you at noon.</BubbleContent>
</Bubble>
</MessageContent>
</Message>
)
}import EsuissUI
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 above and a timestamp below.


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 function MessageWithHeaderAndFooterExample() {
return (
<Message align="start">
<MessageAvatar>
<Avatar>
<AvatarFallback>JL</AvatarFallback>
</Avatar>
</MessageAvatar>
<MessageContent>
<MessageHeader>Jordan Lee</MessageHeader>
<Bubble variant="muted">
<BubbleContent>
I pushed the updated designs to the shared folder.
</BubbleContent>
</Bubble>
<MessageFooter>9:41 AM</MessageFooter>
</MessageContent>
</Message>
)
}import EsuissUI
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) {
MessageAvatar {
Avatar(fallback = { AvatarFallback(text) })
}
}
@Composable
fun MessageWithHeaderAndFooter() {
Message(Modifier.fillMaxWidth()) {
MessageInitials("JL")
MessageContent {
MessageHeader("Jordan Lee")
Bubble(variant = BubbleVariant.Muted) {
BubbleContent("I pushed the updated designs to the shared folder.")
}
MessageFooter("9:41 AM")
}
}
}Conversation
A MessageGroup with an incoming and an outgoing message, including a read receipt footer.


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 function MessageConversationExample() {
return (
<MessageGroup className="gap-4">
<Message>
<MessageAvatar>
<Avatar>
<AvatarFallback>MK</AvatarFallback>
</Avatar>
</MessageAvatar>
<MessageContent>
<Bubble variant="muted">
<BubbleContent>Did the build pass?</BubbleContent>
</Bubble>
<Bubble variant="muted">
<BubbleContent>I want to ship before the weekend.</BubbleContent>
</Bubble>
</MessageContent>
</Message>
<Message align="end">
<MessageContent>
<Bubble>
<BubbleContent>All green. Merging it now.</BubbleContent>
</Bubble>
<MessageFooter className="gap-1">
<Icon as={ChecksIcon} className="text-accent" />
<Text>Read 10:02 AM</Text>
</MessageFooter>
</MessageContent>
</Message>
</MessageGroup>
)
}import EsuissUI
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.")
}
}
}
Message(align: .end) {
MessageContent {
Bubble {
BubbleContent("All green. Merging it now.")
}
MessageFooter {
Ph.checks.regular
.frame(width: 16, height: 16)
.foregroundStyle(Color.accent)
Text("Read 10:02 AM")
}
}
}
}
}
}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
import com.esuiss.ui.components.MessageAlign
import com.esuiss.ui.components.MessageAvatar
import com.esuiss.ui.components.MessageContent
import com.esuiss.ui.components.MessageFooter
import com.esuiss.ui.components.MessageGroup
import com.esuiss.ui.components.Text
import com.esuiss.ui.theme.EsuissTheme
@Composable
fun MessageInitials(text: String) {
MessageAvatar {
Avatar(fallback = { AvatarFallback(text) })
}
}
@Composable
fun MessageConversation() {
MessageGroup(Modifier.fillMaxWidth()) {
Column(verticalArrangement = Arrangement.spacedBy(16.dp)) {
Message(Modifier.fillMaxWidth()) {
MessageInitials("MK")
MessageContent {
Bubble(variant = BubbleVariant.Muted) {
BubbleContent("Did the build pass?")
}
Bubble(variant = BubbleVariant.Muted) {
BubbleContent("I want to ship before the weekend.")
}
}
}
Message(Modifier.fillMaxWidth(), align = MessageAlign.End) {
MessageContent {
Bubble {
BubbleContent("All green. Merging it now.")
}
MessageFooter {
Icon(PhosphorIcons.Regular.Checks, contentDescription = null, tint = EsuissTheme.colors.accent)
Text("Read 10:02 AM")
}
}
}
}
}
}API Reference
MessageGroup
Vertical stack of messages.
ViewPropsMessage
Row that holds the avatar and content and sets the alignment.
ViewProps- About
- Side of the row:
start(default) orend. Also aligns nested bubbles and the footer. - Type
MessageAlign- Default
- "start"
MessageAvatar
Round slot for an avatar, pinned to the bottom of the row.
ViewPropsMessageContent
Column of bubbles built on BubbleGroup.
React.ComponentProps<typeof BubbleGroup>MessageHeader
Small secondary text above the bubbles.
ViewPropsMessageFooter
Small secondary text below the bubbles, aligned with the message side.
ViewPropsAccessibility
- Messages are plain
ViewandTextelements, so screen readers read the header, bubble text and footer in order. - Give avatars without visible text, such as images, an
accessibilityLabel.
Notes
- Header and footer text use
text-xs text-label-secondary, with icons atsize-3.5. - The avatar slot uses
bg-surface-secondary. - Light and dark colors follow the system appearance.