Cards
Cardsanimated

Song Like Burst

Song row where tapping the heart triggers a burst scale-and-fade animation.

Velvet Sky
Mira J

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 SongLikeBurst(title: String, artist: String) {
  var liked by remember { mutableStateOf(false) }
  val scale by animateFloatAsState(
    targetValue = if (liked) 1.3f else 1f,
    animationSpec = spring(
      dampingRatio = Spring.DampingRatioMediumBouncy,
    ),
    label = "burst",
  )
  Card(
    shape = RoundedCornerShape(18.dp),
    modifier = Modifier.fillMaxWidth(),
  ) {
    Row(
      verticalAlignment = Alignment.CenterVertically,
      modifier = Modifier.padding(14.dp),
    ) {
      Box(
        modifier = Modifier
          .size(48.dp)
          .clip(RoundedCornerShape(10.dp))
          .background(
            Brush.linearGradient(
              listOf(Color(0xFF8B5CF6), Color(0xFF06B6D4)),
            ),
          ),
      )
      Spacer(Modifier.width(14.dp))
      Column(Modifier.weight(1f)) {
        Text(title, style = MaterialTheme.typography.titleSmall)
        Text(
          artist,
          style = MaterialTheme.typography.bodySmall,
          color = MaterialTheme.colorScheme.onSurfaceVariant,
        )
      }
      IconButton(onClick = { liked = !liked }) {
        Icon(
          if (liked) Icons.Filled.Favorite
          else Icons.Outlined.FavoriteBorder,
          contentDescription = null,
          tint = if (liked) Color(0xFFEF4444)
          else MaterialTheme.colorScheme.onSurfaceVariant,
          modifier = Modifier.graphicsLayer {
            scaleX = scale; scaleY = scale
          },
        )
      }
    }
  }
}