
Provides tools for creating and managing material themes in Jetpack Compose. Supports theme configuration via JSON, resources, and InputStreams, with examples for seamless cross-platform integration.
A Kotlin Multiplatform library for creating and managing Material 3 themes in Jetpack Compose with a type-safe DSL
Add the library to your build.gradle.kts:
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("xyz.malefic.compose:theming:2.0.0")
}
}
}
}The simplest possible theme - just specify a primary color:
MaleficTheme(
theme = themeConfig {
primary = Color(0xFF6200EE)
}
) {
// Your UI here
}All other colors are automatically derived with intelligent defaults!
Specify as much or as little as you want:
// Minimal - just primary and background
MaleficTheme(
theme = themeConfig {
primary = Color(0xFF6200EE)
background = Color.White
}
) {
// Your content
}
// More customization
MaleficTheme(
theme = themeConfig {
primary = Color(0xFF6200EE)
onPrimary = Color.White
secondary = Color(0xFF03DAC6)
background = Color(0xFFFFFBFE)
surface = Color(0xFFFFFBFE)
error = Color(0xFFB3261E)
}
) {
// Your content
}
// Use hex strings with the extension
MaleficTheme(
theme = themeConfig {
primary = "#6200EE".toColor()
secondary = "#03DAC6".toColor()
background = "#FFFBFE".toColor()
}
) {
// Your content
}
// Full Material 3 customization (if needed)
MaleficTheme(
theme = themeConfig {
primary = Color(0xFF6200EE)
onPrimary = Color.White
primaryContainer = Color(0xFFEADDFF)
onPrimaryContainer = Color(0xFF21005E)
secondary = Color(0xFF03DAC6)
// ... customize all 47 Material 3 colors
}
) {
// Your content
}No configuration needed? Use the default theme:
MaleficTheme {
// Your content with default Material 3 colors
}.toColor() extensionIf you were using the old file-based approach:
Old (1.x):
val themeJson = """{"primary": "#FF6200EE", ...}"""
MaleficThemeFromJson(jsonContent = themeJson) { }New (2.x):
MaleficTheme(
theme = themeConfig {
primary = "#6200EE".toColor()
// Only specify what you need!
}
) { }π€ Om Gupta
Feel free to reach out! :D
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)Please make sure to update tests as appropriate.
Give a βοΈ if this project helped you!
MIT License
Copyright (c) 2024 Om Gupta
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This README was generated by readgen β€
A Kotlin Multiplatform library for creating and managing Material 3 themes in Jetpack Compose with a type-safe DSL
Add the library to your build.gradle.kts:
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("xyz.malefic.compose:theming:2.0.0")
}
}
}
}The simplest possible theme - just specify a primary color:
MaleficTheme(
theme = themeConfig {
primary = Color(0xFF6200EE)
}
) {
// Your UI here
}All other colors are automatically derived with intelligent defaults!
Specify as much or as little as you want:
// Minimal - just primary and background
MaleficTheme(
theme = themeConfig {
primary = Color(0xFF6200EE)
background = Color.White
}
) {
// Your content
}
// More customization
MaleficTheme(
theme = themeConfig {
primary = Color(0xFF6200EE)
onPrimary = Color.White
secondary = Color(0xFF03DAC6)
background = Color(0xFFFFFBFE)
surface = Color(0xFFFFFBFE)
error = Color(0xFFB3261E)
}
) {
// Your content
}
// Use hex strings with the extension
MaleficTheme(
theme = themeConfig {
primary = "#6200EE".toColor()
secondary = "#03DAC6".toColor()
background = "#FFFBFE".toColor()
}
) {
// Your content
}
// Full Material 3 customization (if needed)
MaleficTheme(
theme = themeConfig {
primary = Color(0xFF6200EE)
onPrimary = Color.White
primaryContainer = Color(0xFFEADDFF)
onPrimaryContainer = Color(0xFF21005E)
secondary = Color(0xFF03DAC6)
// ... customize all 47 Material 3 colors
}
) {
// Your content
}No configuration needed? Use the default theme:
MaleficTheme {
// Your content with default Material 3 colors
}.toColor() extensionIf you were using the old file-based approach:
Old (1.x):
val themeJson = """{"primary": "#FF6200EE", ...}"""
MaleficThemeFromJson(jsonContent = themeJson) { }New (2.x):
MaleficTheme(
theme = themeConfig {
primary = "#6200EE".toColor()
// Only specify what you need!
}
) { }π€ Om Gupta
Feel free to reach out! :D
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)Please make sure to update tests as appropriate.
Give a βοΈ if this project helped you!
MIT License
Copyright (c) 2024 Om Gupta
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This README was generated by readgen β€