Charts
Chartsanimated

Segmented progress

A single 100% bar split into labelled category segments that wipe in together.

DirectSocialEmailOther

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 SegmentedProgress(
    segments: List<Triple<String, Float, Color>> = listOf(
        Triple("Direct", 0.42f, Color(0xFF6366F1)),
        Triple("Social", 0.28f, Color(0xFF22D3EE)),
        Triple("Email", 0.18f, Color(0xFFF59E0B)),
        Triple("Other", 0.12f, Color(0xFFF43F5E)),
    ),
    modifier: Modifier = Modifier,
) {
    val reveal by animateFloatAsState(1f, tween(900, easing = EaseOutCubic), label = "r")
    Column(modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(10.dp)) {
        Canvas(Modifier.fillMaxWidth().height(16.dp).clip(RoundedCornerShape(50))) {
            var x = 0f
            segments.forEach { (_, frac, color) ->
                val w = size.width * frac
                drawRect(color, Offset(x * 1f, 0f), Size(w, size.height), alpha = reveal)
                x += w
            }
        }
        Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
            segments.forEach { (label, _, color) ->
                Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp)) {
                    Box(Modifier.size(8.dp).background(color, CircleShape))
                    Text(label, style = MaterialTheme.typography.labelSmall)
                }
            }
        }
    }
}