Skip to main content
FieldValue
Kotlin XML ViewsOverride XML theme attributes in themes.xml extending CometChatTheme.DayNight, or use CometChatTheme.setPrimaryColor() programmatically
Jetpack ComposeWrap content in CometChatTheme {} composable, customize via CometChatColorScheme, CometChatTypography, and Shapes
Key color tokensprimary, backgroundColor1, backgroundColor2, textColorPrimary, textColorSecondary, strokeColorDefault
Dark modeKotlin: values-night/themes.xml overrides. Compose: provide a different CometChatColorScheme based on isSystemInDarkTheme()
Create and apply a global CometChat UI Kit theme that matches your brand across light and dark modes.

When to use this

  • You want a single UI Kit theme that matches your app branding.
  • You need light and dark mode support with consistent colors.
  • You want to customize primary, background, or text colors across all UI Kit components.

Prerequisites


Core Concepts

The Kotlin XML UI Kit uses Android’s theme attribute system. All components read colors, typography, and fonts from XML theme attributes prefixed with cometchat.
  • CometChatTheme.DayNight — base theme built on Theme.MaterialComponents.DayNight.NoActionBar
  • Theme attributes like cometchatPrimaryColor, cometchatBackgroundColor1, etc. are defined in your themes.xml
  • Programmatic access via CometChatTheme.getPrimaryColor(context) and CometChatTheme.setPrimaryColor(color)
  • Dark mode via values-night/themes.xml overrides
Precedence:
  1. Programmatic overrides via CometChatTheme.set*() (highest)
  2. Activity-level theme
  3. Application-level theme
  4. CometChatTheme.DayNight defaults (lowest)

Quick Start

1

Create your theme

In app/src/main/res/values/themes.xml, extend CometChatTheme.DayNight:
themes.xml
<resources>
    <style name="AppTheme" parent="CometChatTheme.DayNight">
        <!-- Your customizations go here -->
    </style>
</resources>
2

Apply the theme

In AndroidManifest.xml, set the theme on your application:
AndroidManifest.xml
<application
    android:theme="@style/AppTheme"
    ...>
</application>
3

Build and verify

Run the app and confirm UI Kit screens use your theme in both light and dark mode.

Change the Primary Color

Override cometchatPrimaryColor in your theme:
themes.xml
<style name="AppTheme" parent="CometChatTheme.DayNight">
    <item name="cometchatPrimaryColor">#F76808</item>
</style>
Or set it programmatically:
CometChatTheme.setPrimaryColor(Color.parseColor("#F76808"))

Customize Common Theme Attributes

themes.xml
<style name="AppTheme" parent="CometChatTheme.DayNight">
    <!-- Primary brand color -->
    <item name="cometchatPrimaryColor">#6851D6</item>

    <!-- Background colors -->
    <item name="cometchatBackgroundColor1">#FFFFFF</item>
    <item name="cometchatBackgroundColor2">#F5F5F5</item>

    <!-- Text colors -->
    <item name="cometchatTextColorPrimary">#000000</item>
    <item name="cometchatTextColorSecondary">#666666</item>

    <!-- Border and divider colors -->
    <item name="cometchatStrokeColorDefault">#E0E0E0</item>
</style>
Or programmatically:
CometChatTheme.setPrimaryColor(Color.parseColor("#6851D6"))
CometChatTheme.setBackgroundColor1(Color.parseColor("#FFFFFF"))
CometChatTheme.setBackgroundColor2(Color.parseColor("#F5F5F5"))
CometChatTheme.setTextColorPrimary(Color.parseColor("#000000"))
CometChatTheme.setTextColorSecondary(Color.parseColor("#666666"))
CometChatTheme.setStrokeColorDefault(Color.parseColor("#E0E0E0"))

Add Dark Mode Support

Create app/src/main/res/values-night/themes.xml and override attributes for dark mode:
values-night/themes.xml
<resources>
    <style name="AppTheme" parent="CometChatTheme.DayNight">
        <item name="cometchatPrimaryColor">#8B7FFF</item>
        <item name="cometchatBackgroundColor1">#1A1A1A</item>
        <item name="cometchatTextColorPrimary">#FFFFFF</item>
    </style>
</resources>
Android automatically applies values-night overrides when the system uses dark mode.

Apply a Theme to a Specific Activity

Set android:theme on a specific <activity> in AndroidManifest.xml:
AndroidManifest.xml
<application android:theme="@style/AppTheme" ...>
    <activity
        android:name=".ChatActivity"
        android:theme="@style/ChatTheme" />
</application>
Activity-level themes override the application-level theme.

Color Token Reference

TokenDescription
primaryButtons, highlights, interactive elements
backgroundColor1Main surface/panel background
backgroundColor2Secondary surface background
backgroundColor3Tertiary surface background
backgroundColor4Quaternary surface background
textColorPrimaryPrimary text
textColorSecondarySecondary/subtitle text
textColorTertiaryTertiary/hint text
textColorHighlightHighlighted/linked text
strokeColorDefaultDefault borders and dividers
strokeColorLightLight borders
strokeColorDarkDark borders
successColorSuccess indicators
errorColorError indicators
warningColorWarning indicators
infoColorInfo indicators