Cards
Cardsanimated

Color Swatch Picker

Product card with circular color swatches and an animated active ring.

Color

Installation

caveui components are copy-paste Jetpack Compose built entirely on Material 3 — there's no caveui dependency to add. Make sure Material 3 is on your classpath (it ships with the Compose BOM), then copy the Usage snippet below into your project.

kotlin
// build.gradle.kts (module)
dependencies {
    implementation(platform("androidx.compose:compose-bom:2025.06.00"))
    implementation("androidx.compose.material3:material3")
}

Usage

kotlin
@Composable
fun ColorSwatchCard() {
  val colors = listOf(
    Color(0xFFEF4444), Color(0xFF3B82F6),
    Color(0xFF10B981), Color(0xFFF59E0B)
  )
  var sel by remember { mutableStateOf(0) }
  Card(
    modifier = Modifier.width(240.dp),
    shape = RoundedCornerShape(18.dp)
  ) {
    Column(Modifier.padding(16.dp)) {
      Box(
        Modifier
          .fillMaxWidth()
          .height(110.dp)
          .clip(RoundedCornerShape(12.dp))
          .background(colors[sel].copy(alpha = 0.25f))
      )
      Spacer(Modifier.height(12.dp))
      Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
        colors.forEachIndexed { i, c ->
          val ring by animateDpAsState(
            if (i == sel) 3.dp else 0.dp, label = "r")
          Box(
            Modifier
              .size(28.dp)
              .border(ring, MaterialTheme.colorScheme.onSurface,
                CircleShape)
              .padding(4.dp)
              .clip(CircleShape)
              .background(c)
              .clickable { sel = i }
          )
        }
      }
    }
  }
}