ColorSwatchPicker

fun ColorSwatchPicker(colors: List<Color>, selectedIndex: Int, onSwatchSelected: (Int) -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true, swatchSize: Dp = ColorSwatchPickerDefaults.SwatchSize, cellSize: Dp = ColorSwatchPickerDefaults.CellSize, ringStrokeWidth: Dp = ColorSwatchPickerDefaults.RingStrokeWidth, ringColor: Color = COUITheme.colorScheme.primary, spacing: Dp = ColorSwatchPickerDefaults.Spacing)

A ColorSwatchPicker component with COUI style.

A horizontal row of circular color swatches with an animated selection ring, mirroring the ColorOS 16 icon mono-color selector (UxColorSelectableView): a 34dp color dot inside a 44dp cell, with a 2dp theme-colored ring that fades in on selection.

Note: colors is a standard List, which Compose treats as unstable; build it inside a remember { } block (or keep the same instance across compositions) to avoid needless recompositions.

Parameters

colors

The list of colors to display as swatches.

selectedIndex

The index of the currently selected swatch, or a negative value for none.

onSwatchSelected

The callback invoked with the index of the swatch the user selects.

modifier

The modifier to be applied to the ColorSwatchPicker.

enabled

Whether the ColorSwatchPicker is enabled.

swatchSize

The diameter of each color dot (COUI ux_icon_color_select_inside).

cellSize

The touch target / selection ring outer diameter (COUI ux_icon_color_select_out).

ringStrokeWidth

The stroke width of the selection ring (COUI ux_theme_shadow_stroke).

ringColor

The color of the selection ring (COUI couiColorPrimary).

spacing

The spacing between adjacent cells.