Badges
Badgesanimated

Unlock

An access chip that morphs from a closed lock to an open one when granted.

LockedUnlocked

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
var unlocked by remember { mutableStateOf(false) }
LaunchedEffect(Unit) {
    while (true) { unlocked = false; delay(1400); unlocked = true; delay(1400) }
}
val color = if (unlocked) Color(0xFF16A34A)
    else MaterialTheme.colorScheme.onSurfaceVariant
Surface(
    shape = RoundedCornerShape(50),
    color = MaterialTheme.colorScheme.surfaceVariant,
    contentColor = color,
) {
    Row(
        Modifier.padding(horizontal = 10.dp, vertical = 4.dp),
        verticalAlignment = Alignment.CenterVertically,
        horizontalArrangement = Arrangement.spacedBy(6.dp),
    ) {
        AnimatedContent(
            targetState = unlocked,
            transitionSpec = { scaleIn() + fadeIn() togetherWith scaleOut() + fadeOut() },
            label = "lock",
        ) { open ->
            Icon(
                if (open) Icons.Filled.LockOpen else Icons.Filled.Lock,
                contentDescription = null,
                modifier = Modifier.size(14.dp),
            )
        }
        Text(if (unlocked) "Unlocked" else "Locked", fontSize = 12.sp)
    }
}