Icons
Iconsanimated

Thumbs up

A thumbs-up that springs up with an approving pop ring — for upvotes and approvals.

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 ThumbsUp(liked: Boolean, onClick: () -> Unit) {
    val scale by animateFloatAsState(if (liked) 1f else 0.9f,
        spring(Spring.DampingRatioMediumBouncy, 500f), label = "t")
    val burst by animateFloatAsState(if (liked) 1f else 0f, tween(450), label = "b")
    val color = MaterialTheme.colorScheme.primary
    Box(Modifier.size(40.dp).clickable(onClick = onClick), contentAlignment = Alignment.Center) {
        if (burst in 0f..1f) Canvas(Modifier.matchParentSize()) {
            drawCircle(color.copy(alpha = 1f - burst), size.minDimension / 2 * burst, style = Stroke(2.dp.toPx()))
        }
        Icon(Icons.Filled.ThumbUp, "Like", tint = color, modifier = Modifier.scale(scale))
    }
}