withPredefinedColorHint
Adds predefined color hints to a Color field for quick selection.
Wraps the field with hint buttons for all colors in ColorField.predefinedColorNames, allowing users to quickly select common colors like Color.Red, Color.Blue, etc.
Usage
@Preview
@Composable
fun ColorPreview() = PreviewLab {
val backgroundColor = fieldValue {
ColorField("Background", Color.White).withPredefinedColorHint()
}
Box(
modifier = Modifier
.size(100.dp)
.background(backgroundColor)
)
}Content copied to clipboard
The hints appear as clickable buttons below the color picker, labeled with the color names (e.g., "Color.Red", "Color.Blue"). Clicking a hint sets the field to that color value.
Return
A new field wrapped with predefined color hints