Charts
Chartsanimated
Segmented ring
A circular meter of discrete segment ticks that light up around the ring.
71%
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 SegmentedRing(
total: Int = 24,
filled: Int = 17,
accent: Color = Color(0xFF14B8A6),
modifier: Modifier = Modifier,
) {
val progress = remember { Animatable(0f) }
LaunchedEffect(Unit) { progress.animateTo(filled.toFloat(), tween(1100, easing = EaseOutCubic)) }
val track = MaterialTheme.colorScheme.surfaceVariant
Box(modifier.size(140.dp), contentAlignment = Alignment.Center) {
Canvas(Modifier.fillMaxSize()) {
val seg = 360f / total
val r = size.minDimension / 2 - 8.dp.toPx()
repeat(total) { i ->
val lit = i < progress.value.toInt()
drawArc(
if (lit) accent else track,
-90f + i * seg + 2f, seg - 4f, false,
topLeft = center - Offset(r, r), size = Size(r * 2, r * 2),
style = Stroke(10.dp.toPx(), cap = StrokeCap.Round),
)
}
}
Text("71%", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold)
}
}