| name | cometchat-ios-theming |
| description | Customize the look and feel of CometChat iOS UI Kit — colors, fonts, styles, and dark mode support. |
| license | MIT |
| compatibility | CometChatUIKitSwift ^5; iOS 13+ |
| metadata | {"author":"CometChat","version":"3.0.0","tags":"chat cometchat ios theming colors fonts styles dark-mode"} |
Ground truth: CometChatUIKitSwift ~> 5 (+ CometChatCallsSDK ~> 5) — Pods/SPM .swiftinterface + ui-kit/ios. Official docs: https://www.cometchat.com/docs/ui-kit/ios/overview · Docs MCP: claude mcp add --transport http cometchat-docs https://www.cometchat.com/docs/mcp (or fetch the URL directly without MCP). Verify symbols against the installed package/source before relying on them.
Purpose
This skill teaches how to customize the visual appearance of CometChat iOS UI Kit components. It covers global theming, component-level styling, dark mode support, and creating custom themes.
1. Global Theme Configuration
CometChat iOS UI Kit uses CometChatTheme for global styling. Configure it early in your app lifecycle, before showing any CometChat UI.
Primary Colors
import CometChatUIKitSwift
CometChatTheme.primaryColor = UIColor.systemBlue
CometChatTheme.extendedPrimaryColor50 = UIColor.systemBlue.withAlphaComponent(0.05)
CometChatTheme.extendedPrimaryColor100 = UIColor.systemBlue.withAlphaComponent(0.1)
CometChatTheme.extendedPrimaryColor200 = UIColor.systemBlue.withAlphaComponent(0.2)
CometChatTheme.extendedPrimaryColor300 = UIColor.systemBlue.withAlphaComponent(0.3)
CometChatTheme.extendedPrimaryColor400 = UIColor.systemBlue.withAlphaComponent(0.4)
CometChatTheme.extendedPrimaryColor500 = UIColor.systemBlue.withAlphaComponent(0.5)
CometChatTheme.extendedPrimaryColor600 = UIColor.systemBlue.withAlphaComponent(0.6)
CometChatTheme.extendedPrimaryColor700 = UIColor.systemBlue.withAlphaComponent(0.7)
CometChatTheme.extendedPrimaryColor800 = UIColor.systemBlue.withAlphaComponent(0.8)
CometChatTheme.extendedPrimaryColor900 = UIColor.systemBlue.withAlphaComponent(0.9)
Background Colors
CometChatTheme.backgroundColor01 = UIColor.systemBackground
CometChatTheme.backgroundColor02 = UIColor.secondarySystemBackground
CometChatTheme.backgroundColor03 = UIColor.tertiarySystemBackground
CometChatTheme.backgroundColor04 = UIColor.quaternarySystemFill
Text Colors
CometChatTheme.textColorPrimary = UIColor.label
CometChatTheme.textColorSecondary = UIColor.secondaryLabel
CometChatTheme.textColorTertiary = UIColor.tertiaryLabel
CometChatTheme.textColorDisabled = UIColor.placeholderText
CometChatTheme.textColorWhite = UIColor.white
CometChatTheme.textColorHighlight = UIColor.systemBlue
Icon Colors
CometChatTheme.iconColorPrimary = UIColor.label
CometChatTheme.iconColorSecondary = UIColor.secondaryLabel
CometChatTheme.iconColorTertiary = UIColor.tertiaryLabel
CometChatTheme.iconColorWhite = UIColor.white
CometChatTheme.iconColorHighlight = UIColor.systemBlue
Border Colors
CometChatTheme.borderColorDefault = UIColor.separator
CometChatTheme.borderColorLight = UIColor.separator.withAlphaComponent(0.5)
CometChatTheme.borderColorDark = UIColor.opaqueSeparator
CometChatTheme.borderColorHighlight = UIColor.systemBlue
Status Colors
CometChatTheme.successColor = UIColor.systemGreen
CometChatTheme.warningColor = UIColor.systemOrange
CometChatTheme.errorColor = UIColor.systemRed
CometChatTheme.infoColor = UIColor.systemBlue
Neutral Colors (50-900 scale)
CometChatTheme.neutralColor50 = UIColor.systemGray6
CometChatTheme.neutralColor100 = UIColor.systemGray5
CometChatTheme.neutralColor200 = UIColor.systemGray4
CometChatTheme.neutralColor300 = UIColor.systemGray3
CometChatTheme.neutralColor400 = UIColor.systemGray2
CometChatTheme.neutralColor500 = UIColor.systemGray
CometChatTheme.neutralColor600 = UIColor.darkGray
CometChatTheme.neutralColor700 = UIColor.gray
CometChatTheme.neutralColor800 = UIColor.lightGray
CometChatTheme.neutralColor900 = UIColor.black
2. Typography
Font Configuration
import CometChatUIKitSwift
var customTypography = Typography()
let avenirFamily = CometChatFontFamily(
regular: "Avenir",
medium: "Avenir-Medium",
bold: "Avenir-Heavy"
)
customTypography.overrideFont(family: avenirFamily)
CometChatTypography.Heading1.bold = UIFont.systemFont(ofSize: 28, weight: .bold)
CometChatTypography.Heading2.bold = UIFont.systemFont(ofSize: 24, weight: .bold)
CometChatTypography.Heading3.bold = UIFont.systemFont(ofSize: 20, weight: .bold)
CometChatTypography.Heading4.medium = UIFont.systemFont(ofSize: 18, weight: .medium)
..regular .systemFont(ofSize: , weight: .regular)
..medium .systemFont(ofSize: , weight: .medium)
..bold .systemFont(ofSize: , weight: .bold)
..regular .systemFont(ofSize: , weight: .regular)
..medium .systemFont(ofSize: , weight: .medium)
..regular .systemFont(ofSize: , weight: .regular)
..medium .systemFont(ofSize: , weight: .medium)
Using Custom Fonts
CometChatTypography.Heading1.bold = UIFont(name: "CustomFont-Bold", size: 28) ?? .systemFont(ofSize: 28, weight: .bold)
CometChatTypography.Body.regular = UIFont(name: "CustomFont-Regular", size: 16) ?? .systemFont(ofSize: 16, weight: .regular)
3. Spacing
CometChat uses nested classes for spacing configuration.
Spacing Configuration
import CometChatUIKitSwift
CometChatSpacing.Spacing.s = 2
CometChatSpacing.Spacing.s1 = 4
CometChatSpacing.Spacing.s2 = 8
CometChatSpacing.Spacing.s3 = 12
CometChatSpacing.Spacing.s4 = 16
CometChatSpacing.Spacing.s5 = 20
CometChatSpacing.Spacing.s6 = 24
CometChatSpacing.Spacing.s7 = 28
CometChatSpacing.Spacing.s8 = 32
CometChatSpacing.Spacing.s9 = 36
CometChatSpacing.Spacing.s10 = 40
CometChatSpacing.Padding.p = 2
CometChatSpacing.Padding.p1 = 4
..p2
..p3
..p4
..p5
..p6
..r
..r1
..r2
..r3
..r4
..r5
..r6
..rMax
..m
..m1
..m2
..m3
..m4
Using Spacing Values
let padding = CometChatSpacing.Padding.p3
let cornerRadius = CometChatSpacing.Radius.r2
let style = CometChatCornerStyle(cornerRadius: CometChatSpacing.Radius.r2)
4. Component-Level Styling
Each CometChat component has a static style property. Modify these to customize appearance globally.
CometChatConversations Style
CometChatConversations.style.backgroundColor = .systemBackground
CometChatConversations.style.borderWidth = 0
CometChatConversations.style.borderColor = .clear
CometChatConversations.style.cornerRadius = CometChatCornerStyle(cornerRadius: 0)
CometChatConversations.style.titleFont = CometChatTypography.Heading4.medium
CometChatConversations.style.titleColor = CometChatTheme.textColorPrimary
CometChatConversations.style.largeTitleFont = CometChatTypography.Heading1.bold
CometChatConversations.style.largeTitleColor = CometChatTheme.textColorPrimary
CometChatConversations.style.listItemTitleTextColor = CometChatTheme.textColorPrimary
CometChatConversations.style.listItemTitleFont = CometChatTypography.Heading4.medium
CometChatConversations.style.listItemSubTitleTextColor = CometChatTheme.textColorSecondary
CometChatConversations.style.listItemSubTitleFont = CometChatTypography.Body.regular
CometChatConversations.style.listItemBackground = .clear
CometChatConversations.style.listItemSelectedBackground .backgroundColor04
.style.emptyTitleTextFont ..bold
.style.emptyTitleTextColor .textColorPrimary
.style.emptySubTitleFont ..regular
.style.emptySubTitleTextColor .textColorSecondary
.style.errorTitleTextFont ..bold
.style.errorTitleTextColor .textColorPrimary
.style.errorSubTitleFont ..regular
.style.errorSubTitleTextColor .textColorSecondary
.style.retryButtonTextColor .buttonTextColor
.style.retryButtonTextFont ..medium
.style.retryButtonBackgroundColor .primaryColor
.style.privateGroupImageTintColor .backgroundColor01
.style.privateGroupImageBackgroundColor .successColor
.style.passwordGroupImageTintColor .backgroundColor01
.style.passwordGroupImageBackgroundColor .warningColor
.style.messageTypeImageTint .iconColorSecondary
CometChatMessageList Style
CometChatMessageList.style.backgroundColor = CometChatTheme.backgroundColor02
CometChatMessageList.style.borderWidth = 0
CometChatMessageList.style.borderColor = .clear
CometChatMessageList.style.shimmerGradientColor1 = CometChatTheme.backgroundColor04
CometChatMessageList.style.shimmerGradientColor2 = CometChatTheme.backgroundColor03
CometChatMessageList.style.emptyStateTitleColor = CometChatTheme.textColorPrimary
CometChatMessageList.style.emptyStateTitleFont = CometChatTypography.Heading3.bold
CometChatMessageList.style.emptyStateSubtitleColor = CometChatTheme.textColorSecondary
CometChatMessageList.style.emptyStateSubtitleFont = CometChatTypography.Body.regular
CometChatMessageList.style.errorStateTitleColor = CometChatTheme.textColorPrimary
CometChatMessageList.style.errorStateTitleFont = CometChatTypography.Heading3.bold
CometChatMessageList.style.errorStateSubtitleColor = CometChatTheme.textColorSecondary
CometChatMessageList.style.errorStateSubtitleFont = CometChatTypography..regular
.style.newMessageIndicatorTextColor .errorColor
.style.newMessageIndicatorBackgroundColor .errorColor
.style.newMessageIndicatorTextFont ..medium
.style.backgroundImage (named: )
CometChatMessageBubble Style
Message bubbles use separate styles for incoming and outgoing messages:
CometChatMessageBubble.style.outgoing.backgroundColor = CometChatTheme.primaryColor
CometChatMessageBubble.style.outgoing.borderWidth = 0
CometChatMessageBubble.style.outgoing.borderColor = .clear
CometChatMessageBubble.style.outgoing.cornerRadius = CometChatCornerStyle(cornerRadius: 16)
CometChatMessageBubble.style.outgoing.headerTextColor = CometChatTheme.primaryColor
CometChatMessageBubble.style.outgoing.headerTextFont = CometChatTypography.Caption1.medium
CometChatMessageBubble.style.incoming.backgroundColor = CometChatTheme.neutralColor300
CometChatMessageBubble.style.incoming.borderWidth = 0
CometChatMessageBubble.style.incoming.borderColor = .clear
CometChatMessageBubble.style.incoming.cornerRadius = CometChatCornerStyle(cornerRadius: 16)
CometChatMessageBubble.style.incoming.headerTextColor = CometChatTheme.primaryColor
CometChatMessageBubble.style.incoming.headerTextFont = CometChatTypography.Caption1.medium
CometChatMessageBubble.style.outgoing.textBubbleStyle.textColor = .white
.style.outgoing.textBubbleStyle.textFont ..regular
.style.incoming.textBubbleStyle.textColor .textColorPrimary
.style.incoming.textBubbleStyle.textFont ..regular
CometChatMessageComposer Style
CometChatMessageComposer.style.backgroundColor = CometChatTheme.backgroundColor03
CometChatMessageComposer.style.borderWidth = 0
CometChatMessageComposer.style.borderColor = .clear
CometChatMessageComposer.style.placeHolderTextFont = CometChatTypography.Body.regular
CometChatMessageComposer.style.placeHolderTextColor = CometChatTheme.textColorTertiary
CometChatMessageComposer.style.textFiledColor = CometChatTheme.textColorPrimary
CometChatMessageComposer.style.textFiledFont = CometChatTypography.Body.regular
CometChatMessageComposer.style.composeBoxBackgroundColor = CometChatTheme.backgroundColor01
CometChatMessageComposer.style.composeBoxBorderColor = CometChatTheme.borderColorDefault
CometChatMessageComposer.style.composeBoxBorderWidth = 1
CometChatMessageComposer.style.composerBoxCornerRadius = CometChatCornerStyle(cornerRadius: CometChatSpacing.Radius.r2)
CometChatMessageComposer.style.composerSeparatorColor = CometChatTheme.borderColorLight
CometChatMessageComposer.style.sendButtonImageTint .white
.style.activeSendButtonImageBackgroundColor .primaryColor
.style.inactiveSendButtonImageBackgroundColor .neutralColor300
.style.attachmentImageTint .iconColorSecondary
.style.voiceRecordingImageTint .iconColorSecondary
.style.aiImageTint .iconColorSecondary
.style.stickerTint .iconColorSecondary
.style.editPreviewTitleTextFont ..regular
.style.editPreviewTitleTextColor .textColorPrimary
.style.editPreviewMessageTextFont ..regular
.style.editPreviewMessageTextColor .textColorSecondary
.style.editPreviewBackgroundColor .backgroundColor03
.style.editPreviewBorderColor .borderColorHighlight
.style.editPreviewCloseIconTint .iconColorHighlight
CometChatAvatar Style
CometChatAvatar.style.backgroundColor = CometChatTheme.extendedPrimaryColor500
CometChatAvatar.style.textColor = CometChatTheme.white
CometChatAvatar.style.textFont = CometChatTypography.Heading2.bold
CometChatAvatar.style.borderColor = .clear
CometChatAvatar.style.borderWidth = 0
CometChatAvatar.style.cornerRadius = nil
CometChatBadge Style
CometChatBadge.style.backgroundColor = CometChatTheme.primaryColor
CometChatBadge.style.textColor = CometChatTheme.buttonIconColor
CometChatBadge.style.textFont = CometChatTypography.Caption1.regular
CometChatBadge.style.cornerRadius = nil
CometChatBadge.style.borderWidth = 0.5
CometChatBadge.style.borderColor = UIColor.clear.cgColor
CometChatStatusIndicator Style
CometChatStatusIndicator.style.backgroundColor = CometChatTheme.successColor
CometChatStatusIndicator.style.borderColor = CometChatTheme.backgroundColor01
CometChatStatusIndicator.style.borderWidth = 0
CometChatStatusIndicator.style.cornerRadius = nil
CometChatStatusIndicator.style.backgroundImage = nil
CometChatDate Style
CometChatDate.style.textColor = CometChatTheme.textColorPrimary
CometChatDate.style.textFont = CometChatTypography.Caption1.medium
CometChatDate.style.backgroundColor = CometChatTheme.backgroundColor02
CometChatDate.style.borderWidth = 1
CometChatDate.style.borderColor = CometChatTheme.borderColorDark
CometChatDate.style.cornerRadius = nil
CometChatReceipt Style
CometChatReceipt.style.waitImageTintColor = CometChatTheme.iconColorSecondary
CometChatReceipt.style.sentImageTintColor = CometChatTheme.iconColorSecondary
CometChatReceipt.style.deliveredImageTintColor = CometChatTheme.iconColorSecondary
CometChatReceipt.style.readImageTintColor = CometChatTheme.messageReadColor
CometChatReceipt.style.errorImageTintColor = CometChatTheme.iconColorSecondary
CometChatReceipt.style.waitImage = UIImage(systemName: "clock")?.withRenderingMode(.alwaysTemplate) ?? UIImage()
CometChatReceipt.style.sentImage = UIImage(systemName: "checkmark")?.withRenderingMode(.alwaysTemplate) ?? UIImage()
CometChatReceipt.style.deliveredImage = UIImage(systemName: "checkmark.circle")?.withRenderingMode(.alwaysTemplate) ?? UIImage()
CometChatReceipt.style.readImage = UIImage(systemName: "checkmark.circle.fill")?.withRenderingMode(.alwaysTemplate) ?? UIImage()
5. Dark Mode Support
CometChat automatically supports dark mode when using system colors. For custom colors, use dynamic colors:
Using Dynamic Colors
let dynamicPrimary = UIColor { traitCollection in
switch traitCollection.userInterfaceStyle {
case .dark:
return UIColor(red: 0.4, green: 0.6, blue: 1.0, alpha: 1.0)
default:
return UIColor(red: 0.0, green: 0.4, blue: 0.8, alpha: 1.0)
}
}
CometChatTheme.primaryColor = dynamicPrimary
Using Asset Catalog Colors
- Create a Color Set in your asset catalog
- Configure appearances for Any, Light, and Dark
- Reference in code:
CometChatTheme.primaryColor = UIColor(named: "BrandPrimary") ?? .systemBlue
CometChatTheme.backgroundColor01 = UIColor(named: "Background") ?? .systemBackground
Complete Theme Configuration Function
func configureCometChatTheme() {
CometChatTheme.primaryColor = UIColor { trait in
trait.userInterfaceStyle == .dark
? UIColor(red: 0.35, green: 0.55, blue: 0.93, alpha: 1.0)
: UIColor(red: 0.2, green: 0.4, blue: 0.8, alpha: 1.0)
}
CometChatTheme.backgroundColor01 = UIColor { trait in
trait.userInterfaceStyle == .dark
? UIColor(red: 0.11, green: 0.11, blue: 0.12, alpha: 1.0)
: UIColor.white
}
CometChatTheme.backgroundColor02 = UIColor { trait in
trait.userInterfaceStyle == .dark
? UIColor(red: 0.17, green: 0.17, blue: 0.18, alpha: 1.0)
: UIColor(red: 0.95, green: 0.95, blue: 0.97, alpha: 1.0)
}
CometChatTheme.textColorPrimary { trait
trait.userInterfaceStyle .dark
.white
: .black
}
.textColorSecondary { trait
trait.userInterfaceStyle .dark
(red: , green: , blue: , alpha: )
: (red: , green: , blue: , alpha: )
}
}
6. Preset Theme Examples
WhatsApp-like Theme
func applyWhatsAppTheme() {
CometChatTheme.primaryColor = UIColor(red: 0.15, green: 0.83, blue: 0.4, alpha: 1.0)
CometChatTheme.backgroundColor01 = UIColor { trait in
trait.userInterfaceStyle == .dark
? UIColor(red: 0.07, green: 0.11, blue: 0.13, alpha: 1.0)
: UIColor.white
}
CometChatTheme.backgroundColor02 = UIColor { trait in
trait.userInterfaceStyle == .dark
? UIColor(red: 0.12, green: 0.17, blue: 0.2, alpha: 1.0)
: UIColor(red: 0.94, green: 0.95, blue: 0.96, alpha: 1.0)
}
CometChatMessageBubble.style.outgoing.backgroundColor = UIColor { trait in
trait.userInterfaceStyle == .dark
? UIColor(red: 0.0, green: 0.36, blue: 0.29, alpha: )
: (red: , green: , blue: , alpha: )
}
.style.outgoing.textBubbleStyle.textColor { trait
trait.userInterfaceStyle .dark .white : .black
}
.style.incoming.backgroundColor { trait
trait.userInterfaceStyle .dark
(red: , green: , blue: , alpha: )
: .white
}
}
iMessage-like Theme
func applyiMessageTheme() {
CometChatTheme.primaryColor = UIColor(red: 0.0, green: 0.48, blue: 1.0, alpha: 1.0)
CometChatMessageBubble.style.outgoing.backgroundColor = UIColor(red: 0.0, green: 0.48, blue: 1.0, alpha: 1.0)
CometChatMessageBubble.style.outgoing.textBubbleStyle.textColor = .white
CometChatMessageBubble.style.outgoing.cornerRadius = CometChatCornerStyle(cornerRadius: 18)
CometChatMessageBubble.style.incoming.backgroundColor = UIColor { trait in
trait.userInterfaceStyle == .dark
? UIColor(red: 0.23, green: 0.23, blue: 0.24, alpha: 1.0)
: UIColor(red: 0.91, green: 0.91, blue: 0.92, alpha: 1.0)
}
CometChatMessageBubble.style.incoming.textBubbleStyle.textColor = UIColor { trait in
trait.userInterfaceStyle == .dark ? .white : .black
}
.style.incoming.cornerRadius (cornerRadius: )
}
7. Instance-Level Styling
For styling specific instances without affecting global styles:
let conversations = CometChatConversations()
conversations.style.backgroundColor = UIColor.systemPink.withAlphaComponent(0.1)
conversations.style.listItemTitleTextColor = .systemPink
conversations.avatarStyle.backgroundColor = UIColor.systemPink.withAlphaComponent(0.2)
8. Helper Extension
extension UIColor {
convenience init(hex: String) {
var hexSanitized = hex.trimmingCharacters(in: .whitespacesAndNewlines)
hexSanitized = hexSanitized.replacingOccurrences(of: "#", with: "")
var rgb: UInt64 = 0
Scanner(string: hexSanitized).scanHexInt64(&rgb)
let r = CGFloat((rgb & 0xFF0000) >> 16) / 255.0
let g = CGFloat((rgb & 0x00FF00) >> 8) / 255.0
let b = CGFloat(rgb & 0x0000FF) / 255.0
self.init(red: r, green: g, blue: b, alpha: 1.0)
}
}
Localization
To translate the UI, switch the active language, or override individual strings, route to the dedicated cometchat-i18n skill — the canonical cross-family localization reference. iOS uses CometChatLocalize (see cometchat-i18n for the exact iOS signature). It covers bundled languages, custom translations, RTL, and date/time formatting. Docs: https://www.cometchat.com/docs/ui-kit/ios/localize
Sound Manager — custom notification & call sounds
Sounds are a behavioral customization — driven by CometChatSoundManager (an instance class). The UI Kit plays the built-in cues automatically; use this to override a cue with your own audio file. (Docs: ui-kit/ios/sound-manager.)
CometChatSoundManager().play(sound: .incomingMessage)
if let url = Bundle.main.url(forResource: "ping", withExtension: "wav") {
CometChatSoundManager().play(sound: .incomingMessage, customSound: url)
}
CometChatSoundManager().pause()
Best Practices
- Configure theme early — Set theme in
application(_:didFinishLaunchingWithOptions:) before any CometChat UI is shown
- Use system colors — They automatically adapt to dark mode
- Test both modes — Always verify appearance in light and dark mode
- Use dynamic colors — For custom colors that need to adapt to appearance changes
- Maintain contrast — Ensure text is readable against backgrounds (WCAG guidelines)
- Be consistent — Use the same color palette throughout your app
- Consider accessibility — Support Dynamic Type by not hardcoding font sizes where possible