Icons
Iconsanimated

Confetti

A celebratory burst of confetti pieces flying outward — for success and milestone moments.

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 ConfettiBurst(play: Boolean) {
    val t by animateFloatAsState(if (play) 1f else 0f, tween(900, easing = EaseOutCubic), label = "burst")
    val colors = listOf(Color(0xFFF59E0B), Color(0xFFE11D48), Color(0xFF3B82F6), Color(0xFF16A34A))
    Canvas(Modifier.size(40.dp)) {
        repeat(10) { i ->
            val a = (i / 10f) * 2f * PI.toFloat()
            val d = size.minDimension * 0.42f * t
            rotate(i * 36f + t * 90f, pivot = center + Offset(cos(a) * d, sin(a) * d)) {
                drawRect(colors[i % 4].copy(alpha = 1f - t),
                    topLeft = center + Offset(cos(a) * d, sin(a) * d), size = Size(4f, 6f))
            }
        }
    }
}