Charts
Chartsanimated
Funnel
A conversion funnel of stacked trapezoids that narrow and wipe in top to bottom.
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 Funnel(
stages: List<Pair<String, Float>> = listOf(
"Visits" to 1f, "Signups" to 0.62f,
"Trials" to 0.4f, "Paid" to 0.22f,
),
accent: Color = Color(0xFF6366F1),
modifier: Modifier = Modifier,
) {
val reveal by animateFloatAsState(1f, tween(900, easing = EaseOutCubic), label = "r")
Canvas(modifier.fillMaxWidth().height(130.dp)) {
val gap = 6.dp.toPx()
val rowH = (size.height - gap * (stages.size - 1)) / stages.size
stages.forEachIndexed { i, (_, w) ->
val nextW = stages.getOrNull(i + 1)?.second ?: w
val y = i * (rowH + gap)
val topHalf = w * size.width / 2 * reveal
val botHalf = nextW * size.width / 2 * reveal
val path = Path().apply {
moveTo(center.x - topHalf, y)
lineTo(center.x + topHalf, y)
lineTo(center.x + botHalf, y + rowH)
lineTo(center.x - botHalf, y + rowH)
close()
}
drawPath(path, accent.copy(alpha = 0.55f + 0.12f * i))
}
}
}