Cards
Cardsanimated

Add To Cart Morph

Product card whose button morphs into a check when item is added.

Canvas Tote
$34

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 AddToCartMorphCard() {
  var added by remember { mutableStateOf(false) }
  val width by animateDpAsState(if (added) 56.dp else 160.dp)
  ElevatedCard(
    modifier = Modifier.width(240.dp),
    shape = RoundedCornerShape(20.dp)
  ) {
    Column(Modifier.padding(16.dp)) {
      Box(
        Modifier
          .fillMaxWidth()
          .height(120.dp)
          .clip(RoundedCornerShape(14.dp))
          .background(MaterialTheme.colorScheme.surfaceVariant)
      )
      Spacer(Modifier.height(12.dp))
      Text("Wireless Buds", style = MaterialTheme.typography.titleMedium)
      Text("$129.00", color = MaterialTheme.colorScheme.primary)
      Spacer(Modifier.height(12.dp))
      Button(
        onClick = { added = !added },
        modifier = Modifier.width(width).height(48.dp),
        shape = RoundedCornerShape(24.dp)
      ) {
        AnimatedContent(added, label = "cart") { done ->
          if (done) Icon(Icons.Default.Check, null)
          else Row(verticalAlignment = Alignment.CenterVertically) {
            Icon(Icons.Default.ShoppingCart, null)
            Spacer(Modifier.width(8.dp))
            Text("Add to cart")
          }
        }
      }
    }
  }
}