Code sample to enable dark mode in Android | Community
Skip to main content
Answered

Code sample to enable dark mode in Android


Can I please have a code sample on how to implement dark mode (or switch themes) for Android. E.g. something like

import io.intercom.android.sdk.ui.theme.ThemeMode;

Intercom.client().setThemeMode(ThemeMode.DARK);

I noted that Dark Mode was enabled on Android SDK v17.0.0

Best answer by Ebenezer.Laleye

Hi ​@Ron Dul ! Ebenezer here from Engineering Support👋.

  • The SDK uses a ThemeManager to determine the current theme mode (light, dark, or system/default).
  • The IntercomTheme composable applies the correct color palette based on the theme mode.
  • Utility functions are provided to select the appropriate color for the current theme, both in Compose and non-Compose contexts.
  • You can override the theme mode at runtime (e.g., to allow users to toggle between light and dark modes within your app).

You can set the theme mode using the ThemeManager. For example, to force dark mode:

import io.intercom.android.sdk.ui.theme.ThemeManager
import io.intercom.android.sdk.ui.theme.ThemeMode

// To force dark mode
ThemeManager.setSessionOverride(ThemeMode.DARK)

// To force light mode
ThemeManager.setSessionOverride(ThemeMode.LIGHT)

// To follow the system theme
ThemeManager.setSessionOverride(ThemeMode.SYSTEM)

 

If you are using Jetpack Compose, wrap your Intercom Messenger UI in the IntercomTheme composable. The theme will automatically adapt based on the current theme mode:

import io.intercom.android.sdk.ui.theme.IntercomTheme

IntercomTheme {
    // Place your Intercom Messenger UI here
}

 

If you need to select colors manually (e.g., for custom UI elements), use the provided utility:

import io.intercom.android.sdk.utilities.ThemeUtils

val color = ThemeUtils.selectColorForTheme(context, "#FFFFFF", "#14161a")

View original
Did this topic help you find an answer to your question?

3 replies

Forum|alt.badge.img+7

Hi ​@Ron Dul ! Ebenezer here from Engineering Support👋.

  • The SDK uses a ThemeManager to determine the current theme mode (light, dark, or system/default).
  • The IntercomTheme composable applies the correct color palette based on the theme mode.
  • Utility functions are provided to select the appropriate color for the current theme, both in Compose and non-Compose contexts.
  • You can override the theme mode at runtime (e.g., to allow users to toggle between light and dark modes within your app).

You can set the theme mode using the ThemeManager. For example, to force dark mode:

import io.intercom.android.sdk.ui.theme.ThemeManager
import io.intercom.android.sdk.ui.theme.ThemeMode

// To force dark mode
ThemeManager.setSessionOverride(ThemeMode.DARK)

// To force light mode
ThemeManager.setSessionOverride(ThemeMode.LIGHT)

// To follow the system theme
ThemeManager.setSessionOverride(ThemeMode.SYSTEM)

 

If you are using Jetpack Compose, wrap your Intercom Messenger UI in the IntercomTheme composable. The theme will automatically adapt based on the current theme mode:

import io.intercom.android.sdk.ui.theme.IntercomTheme

IntercomTheme {
    // Place your Intercom Messenger UI here
}

 

If you need to select colors manually (e.g., for custom UI elements), use the provided utility:

import io.intercom.android.sdk.utilities.ThemeUtils

val color = ThemeUtils.selectColorForTheme(context, "#FFFFFF", "#14161a")


  • Author
  • New Participant
  • 2 replies
  • July 23, 2025

Thank you, that is very helpful.


  • Author
  • New Participant
  • 2 replies
  • August 19, 2025

When using Intercom Android SDK 17.1.0 we aren’t able to import the ThemeManager and ThemeMode — as if the “ui” folder isn’t included in the SDK package?

Error: “Cannot resolve symbol 'theme'”

Many thanks


Reply