Badges
3
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
val t = rememberInfiniteTransition(label = "ring")
val angle by t.animateFloat(
initialValue = 0f,
targetValue = 0f,
animationSpec = infiniteRepeatable(
keyframes {
durationMillis = 1800
0f at 0
(-12f) at 700
12f at 800
(-9f) at 900
6f at 1000
0f at 1100
},
),
label = "angle",
)
BadgedBox(
badge = {
Badge(containerColor = Color(0xFFEF4444), contentColor = Color.White) {
Text("3", fontSize = 10.sp)
}
},
) {
Icon(
Icons.Outlined.Notifications,
contentDescription = "Alerts",
modifier = Modifier.graphicsLayer {
rotationZ = angle
transformOrigin = TransformOrigin(0.5f, 0.15f)
},
)
}