Icons
Iconsanimated

Error

An error badge whose X strokes in and the whole mark shakes to demand attention.

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 ErrorShake(error: Boolean) {
    val shake = remember { Animatable(0f) }
    LaunchedEffect(error) { if (error) shake.animateTo(0f, keyframes {
        durationMillis = 400; 0f at 0; -6f at 80; 6f at 160; -4f at 240; 0f at 400 }) }
    val color = MaterialTheme.colorScheme.error
    Box(Modifier.size(40.dp).graphicsLayer { translationX = shake.value.dp.toPx() }, contentAlignment = Alignment.Center) {
        Icon(Icons.Filled.Error, "Error", tint = color, modifier = Modifier.size(30.dp))
    }
}