Package-level declarations

Types

Link copied to clipboard

Define the threshold for a contrast ratio.

Link copied to clipboard
class SampledPixels(val pixels: IntArray, val width: Int, val height: Int)

The pixels samplePixels kept, plus the width and height of the sampled grid.

Properties

Link copied to clipboard
val MaterialDynamicColors.controlActivated: DynamicColor

Legacy Android control accent, retained for existing MaterialKolor themes and exports.

Link copied to clipboard
val MaterialDynamicColors.controlHighlight: DynamicColor

Legacy Android control highlight, translucent white in dark mode and black in light mode.

Link copied to clipboard
val MaterialDynamicColors.controlNormal: DynamicColor

Legacy Android secondary control color, mapped to on-surface-variant from the 2025 spec.

Link copied to clipboard

The pixel budget the image helpers quantize by default. Upstream Material Color Utilities recommends resizing to 128 by 128 before quantizing.

Link copied to clipboard

The spring every MaterialKolor color animation falls back to when the caller passes no spec.

Link copied to clipboard
val DynamicScheme.sourceColor: Color

Get the Color used to generate the DynamicScheme.

Link copied to clipboard
val MaterialDynamicColors.textHintInverse: DynamicColor

Legacy Android inverse hint text.

Link copied to clipboard
val MaterialDynamicColors.textPrimaryInverse: DynamicColor

Legacy Android inverse primary text, mapped to inverse-on-surface from the 2025 spec.

Link copied to clipboard
val MaterialDynamicColors.textPrimaryInverseDisableOnly: DynamicColor

Legacy Android inverse primary text for controls with a separate disabled state.

Link copied to clipboard
val MaterialDynamicColors.textSecondaryAndTertiaryInverse: DynamicColor

Legacy Android inverse secondary and tertiary text.

Link copied to clipboard
val MaterialDynamicColors.textSecondaryAndTertiaryInverseDisabled: DynamicColor

Legacy Android disabled inverse secondary and tertiary text.

Functions

Link copied to clipboard
fun Color.animate(animationSpec: AnimationSpec<Color> = defaultColorSpring, label: String = "ColorAnimation", finishedListener: (Color) -> Unit? = null): State<Color>

Animate the color over time, allowing for a smooth transition between different color states.

Link copied to clipboard
fun Color.blend(to: Color, amount: Float = 0.5f): Color
fun Blend.blend(from: Color, to: Color, amount: Float): Color

Blend two colors together. The hue, chroma, and tone of the original color will change.

Link copied to clipboard
fun Color.blendHue(to: Color, amount: Float = 0.5f): Color

Blends this Color into another. The chroma and tone of the original color are maintained.

fun Blend.blendHue(from: Color, to: Color, amount: Float): Color

Blends hue from one Color into another. The chroma and tone of the original color are maintained.

Link copied to clipboard

Contrast ratio is a measure of legibility, its used to compare the lightness of two colors. This method is used commonly in industry due to its use by WCAG.

Link copied to clipboard
fun Color.darken(ratio: Float = 1.1f): Color

Darken the color by the given ratio.

Link copied to clipboard
fun DynamicScheme(seedColor: Color, isDark: Boolean, primary: Color? = null, secondary: Color? = null, tertiary: Color? = null, neutral: Color? = null, neutralVariant: Color? = null, error: Color? = null, style: PaletteStyle = TonalSpot, contrastLevel: Double = Contrast.Default.value, specVersion: ColorSpec.SpecVersion = ColorSpec.SpecVersion.Default, platform: DynamicScheme.Platform = DynamicScheme.Platform.Default): DynamicScheme

Create a DynamicScheme based on the provided colors.

Link copied to clipboard

If color is disliked, lighten it to make it likable.

Link copied to clipboard
fun Hct.Companion.from(color: Color): Hct

Convert a Compose Color to Hct.

fun TonalPalette.Companion.from(color: Color): TonalPalette

Generates a TonalPalette from the given color.

fun TonalPalette.Companion.from(hct: Hct): TonalPalette

Generates a TonalPalette from the given Hct.

fun TonalPalette.Companion.from(argb: Int): TonalPalette

Generates a TonalPalette from the given argb color int.

Link copied to clipboard
fun DynamicColor.getColor(scheme: DynamicScheme): Color

Returns an Color that represents the color of this DynamicColor in the given scheme.

Link copied to clipboard
fun Color.harmonize(other: Color, matchSaturation: Boolean = false): Color

Blend the color's HCT hue towards the other color's HCT hue, in a way that leaves the original color recognizable and recognizably shifted towards the key color.

fun Blend.harmonize(fromColor: Color, toColor: Color, matchSaturation: Boolean = false): Color

Blend the design color's HCT hue towards the key color's HCT hue, in a way that leaves the original color recognizable and recognizably shifted towards the key color.

Link copied to clipboard
fun Color.hasEnoughContrast(other: Color, threshold: ContrastThreshold = ContrastThreshold.WcagAaNormalText): Boolean

Check if the contrast ratio between two colors is greater than or equal to a given threshold.

Link copied to clipboard

Determine a given color is cool.

Link copied to clipboard

Returns true if color is disliked.

Link copied to clipboard

Check if the color is light.

Link copied to clipboard

Determine a given color is warm.

Link copied to clipboard
fun Color.lighten(ratio: Float = 1.0f): Color

Lighten the color by the given ratio.

Link copied to clipboard
fun TonalPalette.onTone(tone: Int, threshold: ContrastThreshold = ContrastThreshold.WcagAaNormalText): Color

Pick the tone from this palette that is readable on top of toneColor at tone.

Link copied to clipboard
fun QuantizerCelebi.quantize(image: ImageBitmap, maxColors: Int, sampleArea: Int = DEFAULT_SAMPLE_AREA): Map<Int, Int>

Quantize the colors in a ImageBitmap to a maximum of maxColors colors.

Link copied to clipboard
fun rememberDynamicScheme(seedColor: Color, isDark: Boolean, primary: Color? = null, secondary: Color? = null, tertiary: Color? = null, neutral: Color? = null, neutralVariant: Color? = null, error: Color? = null, style: PaletteStyle = TonalSpot, contrastLevel: Double = Contrast.Default.value, specVersion: ColorSpec.SpecVersion = ColorSpec.SpecVersion.Default, platform: DynamicScheme.Platform = DynamicScheme.Platform.Default): DynamicScheme

Create and remember a DynamicScheme based on the provided colors.

Link copied to clipboard
fun rememberThemeColor(image: ImageBitmap, fallback: Color, filter: Boolean = true, maxColors: Int = DEFAULT_QUANTIZE_MAX_COLORS, sampleArea: Int = DEFAULT_SAMPLE_AREA): Color

Determine the most suitable color in a ImageBitmap for a UI theme.

Link copied to clipboard
fun rememberThemeColors(image: ImageBitmap, fallback: Color, maxColors: Int = DEFAULT_QUANTIZE_MAX_COLORS, filter: Boolean = true, desired: Int = DEFAULT_DESIRED_COLORS, sampleArea: Int = DEFAULT_SAMPLE_AREA): List<Color>

Determine the most suitable color in a ImageBitmap for a UI theme.

Link copied to clipboard
fun rememberTonalPalette(seed: Color, harmonizeWith: Color? = null): TonalPalette

Create and remember a TonalPalette for a seed color the scheme does not cover.

Link copied to clipboard
fun ImageBitmap.samplePixels(sampleArea: Int = DEFAULT_SAMPLE_AREA): SampledPixels

Nearest-neighbour samples this bitmap down to at most sampleArea pixels.

Link copied to clipboard
fun TemperatureCache.Companion.temperature(color: Color): Double

Value representing cool-warm factor of a color.

Link copied to clipboard
fun TemperatureCache(input: Color): TemperatureCache

Design utilities using color temperature theory.

Link copied to clipboard
fun ImageBitmap.themeColor(fallback: Color, filter: Boolean = true, maxColors: Int = DEFAULT_QUANTIZE_MAX_COLORS, sampleArea: Int = DEFAULT_SAMPLE_AREA): Color

Determine the most suitable color in a ImageBitmap for a UI theme.

Link copied to clipboard
fun ImageBitmap.themeColorOrNull(filter: Boolean = true, maxColors: Int = DEFAULT_QUANTIZE_MAX_COLORS, sampleArea: Int = DEFAULT_SAMPLE_AREA): Color?

Determine the most suitable color in a ImageBitmap for a UI theme or null

Link copied to clipboard
fun ImageBitmap.themeColors(fallback: Color, maxColors: Int = DEFAULT_QUANTIZE_MAX_COLORS, filter: Boolean = true, desired: Int = DEFAULT_DESIRED_COLORS, sampleArea: Int = DEFAULT_SAMPLE_AREA): List<Color>

Rank the colors in a ImageBitmap by their suitability for being used for a UI theme.

Link copied to clipboard
fun Hct.toColor(): Color

Convert HCT to a Compose Color.

Link copied to clipboard

Convert a list of HCT to a list of Compose Color.

Link copied to clipboard
fun Color.toDynamicScheme(isDark: Boolean, style: PaletteStyle, contrastLevel: Double = Contrast.Default.value, specVersion: ColorSpec.SpecVersion = ColorSpec.SpecVersion.Default, platform: DynamicScheme.Platform = DynamicScheme.Platform.Default): DynamicScheme

Generate a DynamicScheme based on the given Color.

Link copied to clipboard
fun Color.toHct(): Hct

Convert a Compose Color to Hct.

Link copied to clipboard
fun List<Color>.toHcts(): List<Hct>

Convert a list of Compose Color to a list of HCT.

Link copied to clipboard
fun Color.toHex(includePrefix: Boolean = true, prefix: String = "#", alwaysIncludeAlpha: Boolean = false): String

Convert the color to a hex string.

Link copied to clipboard

Contrast ratio of two tones. T in HCT, L* in Lab*. Also known as luminance or perpetual luminance.

Link copied to clipboard
fun TonalPalette.toneColor(tone: Int): Color

Get a tonal Color from the TonalPalette with the given tone.