Cards
Cardsanimated
Poll Result Bars
Poll card animating result bars filling to their final vote percentages.
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 PollResultCard() {
val options = listOf("Tabs" to 0.62f, "Spaces" to 0.38f)
Card(
modifier = Modifier.width(290.dp),
shape = RoundedCornerShape(18.dp)
) {
Column(Modifier.padding(18.dp)) {
Text(
"Tabs or spaces?",
style = MaterialTheme.typography.titleSmall
)
Spacer(Modifier.height(14.dp))
options.forEach { (label, pct) ->
val w by animateFloatAsState(
pct, tween(900), label = label
)
Box(
Modifier.fillMaxWidth().height(34.dp)
.clip(RoundedCornerShape(8.dp))
.background(
MaterialTheme.colorScheme
.surfaceVariant
)
) {
Box(
Modifier.fillMaxWidth(w).fillMaxHeight()
.background(
MaterialTheme.colorScheme
.primaryContainer
)
)
Row(
Modifier.fillMaxSize().padding(
horizontal = 10.dp
),
verticalAlignment =
Alignment.CenterVertically,
horizontalArrangement =
Arrangement.SpaceBetween
) {
Text(label)
Text("${(pct * 100).toInt()}%")
}
}
Spacer(Modifier.height(8.dp))
}
}
}
}