firstWithContrastOrNull

fun Color.firstWithContrastOrNull(vararg colors: Color, targetContrast: Float): Color?

Return the first color with a contrast ratio greater or equal to the targetContrast against this color, or null if no color meets the target.

This implements the color-contrast functionality specified in the CSS Color 5 Spec