Material Color Utilities for Kotlin is a cross-platform wrapper written entirely in Kotlin around Google's Material Color Utilities (MCU), making it easy to generate beautiful, accessible, and user-driven color schemes (including Material 3) using advanced color algorithms.
- Add the library dependency to your
build.gradle.ktsfile:
dependencies {
implementation("space.zghoba:material-color-utilities-kotlin:2.1.0")
}- Add a simple example of using the HCT color model. When using HCT, only the hue changes. The tone and chroma remain constant, so colors appear equally bright regardless of their hue.
import hct.Hct
fun main() {
// Same perceived brightness.
// Different hue.
val red = Hct.from(hue = 20.0, 80.0, 60.0).toInt()
val green = Hct.from(hue = 140.0, 80.0, 60.0).toInt()
val blue = Hct.from(hue = 260.0, 80.0, 60.0).toInt()
}Note
The HCT color model isn't the only feature offered by the Material Color Utilities repository. See Capabilities Overview for more information.
This project is licensed under the MIT License — see the LICENSE file.