A Material Design 3 Theme Engine for Android

Android CI
Maven Central

This library allows you to set Material 3 themes to your app. You can also manage dark mode and dynamic colors in your app. All changes are saved to SharedPreferences no need to manage it manually.

Note: This library does not support dynamic colors on devices lower than Android 12 i.e. API 31.



Light Dark

Theme Chooser

Light Dark

How to use

Getting Started

Add the following gradle dependency to your build.gradle

dependencies {
  implementation 'io.github.prathameshmm02.themeEngine:themeEngine:1.0'


Theming is handled by ThemeEngine class. It is a singleton class and you can get the ThemeEngine instance as follows:

val themeEngine = ThemeEngine.getInstance(context)

Apply theme and night mode to given activity, in your activity's onCreate() method, call:


Apply theme and night mode to all activities by registering a ActivityLifecycleCallbacks to your application. In your application class’ onCreate() method, call:


Set Dark theme

Note : Dark theme change is handled no need to call activity.recreate()

// Light mode
themeEngine.themeMode = ThemeMode.LIGHT

// Dark mode
themeEngine.themeMode = ThemeMode.DARK

// Follow System
themeEngine.themeMode = ThemeMode.AUTO

Set Dynamic Colors, you may want to recreate activity after settings this property

themeEngine.isDynamicTheme = true

Set static theme

The theme used when dynamic color is disabled

themeEngine.staticTheme = R.style.Theme_ThemeEngine_Orange

Create ThemeChooserDialog for the user to choose static theme from, this returns an AlertDialog.


    // Set Title
    // Set positive button text and an OnClickListener on the button
    .setPositiveButton("OK") { position, theme ->
      // This sets staticTheme
      themeEngine.staticTheme = theme
    // Set negative button text
    // Set neutral button text and an OnClickListener on the button
    .setNeutralButton("Default") { _, _ ->
        // This resets static theme
        // Recreates activity
    // Set Dialog Icon
    // Create Alert Dialog
    // Show Dialog

Get current app theme, this returns a dynamic theme when dynamic color is enabled, a static theme otherwise.

val theme = themeEngine.getTheme()

Reset static theme to default



ThemeOverlays are used to apply theme colors to activities. This library contains 20 ThemeOverlays one of which is Dynamic which is used only when dynamic color is enabled other are used by user's choice.
The themes are created with MaterialThemeBuilder by using Material Colors.


View Github