Charts
Chartsanimated
Gradient bars
A vertical bar chart with gradient fills that grow in, staggered left to right.
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 GradientBars(
values: List<Float> = listOf(0.45f, 0.72f, 0.58f, 0.9f, 0.64f, 0.81f, 0.52f),
modifier: Modifier = Modifier,
) {
val grow = remember { Animatable(0f) }
LaunchedEffect(Unit) {
grow.animateTo(1f, tween(900, easing = EaseOutCubic))
}
val top = Color(0xFF6366F1)
val bottom = Color(0xFF22D3EE)
Canvas(modifier.fillMaxWidth().height(120.dp)) {
val gap = 10.dp.toPx()
val bw = (size.width - gap * (values.size - 1)) / values.size
values.forEachIndexed { i, v ->
val h = size.height * v * grow.value
val x = i * (bw + gap)
drawRoundRect(
brush = Brush.verticalGradient(listOf(top, bottom)),
topLeft = Offset(x, size.height - h),
size = Size(bw, h),
cornerRadius = CornerRadius(6.dp.toPx()),
)
}
}
}