toComposeColor

Converts a CSS color string to a Compose Color.

Supported formats:

  • Hex colors: "#RGB", "#ARGB", "#RRGGBB", "#AARRGGBB"

  • Named colors: "red", "blue", "green", etc.

Return

Compose Color, or null if the string cannot be parsed

Example usage:

val color1 = "#FF0000".toComposeColor() // Red
val color2 = "blue".toComposeColor() // Blue
val color3 = "#80FF0000".toComposeColor() // Semi-transparent red