
Dynamic theme management library enabling custom theme families, mode switching, persistence, and previewing with Theme Picker UI. Integrates with Material 3 for adaptable styling.
A Kotlin Multiplatform library for dynamic theme management using Jetpack Compose Multiplatform.
It allows you to:
ThemeStore (works with MultiplatformSettings or custom stores)ThemePickerBottomSheet & sample AppScaffold
Add the dependency to your commonMain:
commonMain.dependencies {
implementation("io.github.iammohdzaki.kmpalette:theme-core:<check-tag-eg.0.0.1>")
}Below is the high-level architecture of the Dynamic Theme Multiplatform Library:
Represents a single theme variant (Light or Dark).
val lightTheme = ThemeDefinition(
id = ThemeId("ocean_light"),
displayName = "Ocean Light",
palette = lightPalette
)A pair of Light/Dark themes grouped under a single name.
val oceanFamily = ThemeFamily(
displayName = "Ocean",
light = oceanLight,
dark = oceanDark
)Registers all available themes.
val registry = DefaultThemeRegistry().apply {
registerFamily(oceanFamily)
registerFamily(forestFamily)
}Manages active theme, system mode, and persistence.
val controller = ThemeController(
registry = registry,
store = SettingsThemeStore(Settings()), // pluggable
system = PlatformSystemThemeProvider(),
defaultThemeId = ThemeId("m3_light")
)Applies theme to your UI (Material 3).
DynamicThemeProvider(
controller = controller,
adapter = Material3Adapter(
typography = CustomTypography(),
shapes = CustomShapes()
)
) {
AppScaffold()
}A ready-to-use Bottom Sheet for switching themes:
ThemePickerBottomSheet(
onDismiss = { showSheet = false }
)It shows:
Implement your own ThemeStore if you donβt want to use MultiplatformSettings:
interface ThemeStore {
suspend fun load(): ThemeSelection?
suspend fun save(selection: ThemeSelection)
}Example: SettingsThemeStore using MultiplatformSettings.
A sample scaffold to showcase theme switching:
@Composable
fun App() {
val controller = remember {
val registry = DefaultThemeRegistry().apply {
registerFamilies(DefaultMaterial3Themes.families)
}
ThemeController(
registry = registry,
store = SettingsThemeStore(Settings()), // You can plug any persistence like Multiplatform Settings,DataStore etc.
system = PlatformSystemThemeProvider(),
defaultThemeId = ThemeId("m3_light")
)
}
DynamicThemeProvider(
controller = controller,
adapter = Material3Adapter(),
typography = SansTypography()
) {
AppScaffold()
}
}DataStore, Database)A Kotlin Multiplatform library for dynamic theme management using Jetpack Compose Multiplatform.
It allows you to:
ThemeStore (works with MultiplatformSettings or custom stores)ThemePickerBottomSheet & sample AppScaffold
Add the dependency to your commonMain:
commonMain.dependencies {
implementation("io.github.iammohdzaki.kmpalette:theme-core:<check-tag-eg.0.0.1>")
}Below is the high-level architecture of the Dynamic Theme Multiplatform Library:
Represents a single theme variant (Light or Dark).
val lightTheme = ThemeDefinition(
id = ThemeId("ocean_light"),
displayName = "Ocean Light",
palette = lightPalette
)A pair of Light/Dark themes grouped under a single name.
val oceanFamily = ThemeFamily(
displayName = "Ocean",
light = oceanLight,
dark = oceanDark
)Registers all available themes.
val registry = DefaultThemeRegistry().apply {
registerFamily(oceanFamily)
registerFamily(forestFamily)
}Manages active theme, system mode, and persistence.
val controller = ThemeController(
registry = registry,
store = SettingsThemeStore(Settings()), // pluggable
system = PlatformSystemThemeProvider(),
defaultThemeId = ThemeId("m3_light")
)Applies theme to your UI (Material 3).
DynamicThemeProvider(
controller = controller,
adapter = Material3Adapter(
typography = CustomTypography(),
shapes = CustomShapes()
)
) {
AppScaffold()
}A ready-to-use Bottom Sheet for switching themes:
ThemePickerBottomSheet(
onDismiss = { showSheet = false }
)It shows:
Implement your own ThemeStore if you donβt want to use MultiplatformSettings:
interface ThemeStore {
suspend fun load(): ThemeSelection?
suspend fun save(selection: ThemeSelection)
}Example: SettingsThemeStore using MultiplatformSettings.
A sample scaffold to showcase theme switching:
@Composable
fun App() {
val controller = remember {
val registry = DefaultThemeRegistry().apply {
registerFamilies(DefaultMaterial3Themes.families)
}
ThemeController(
registry = registry,
store = SettingsThemeStore(Settings()), // You can plug any persistence like Multiplatform Settings,DataStore etc.
system = PlatformSystemThemeProvider(),
defaultThemeId = ThemeId("m3_light")
)
}
DynamicThemeProvider(
controller = controller,
adapter = Material3Adapter(),
typography = SansTypography()
) {
AppScaffold()
}
}DataStore, Database)