Icons
Iconsanimated
Lock
A padlock whose shackle lifts and re-seats as it locks and unlocks, with a subtle bounce.
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 LockToggle(locked: Boolean, onToggle: () -> Unit) {
val lift by animateFloatAsState(if (locked) 0f else -4f, spring(stiffness = 400f), label = "lift")
val rot by animateFloatAsState(if (locked) 0f else -18f, spring(stiffness = 400f), label = "rot")
val color = MaterialTheme.colorScheme.primary
Box(Modifier.size(40.dp).clickable(onClick = onToggle), contentAlignment = Alignment.Center) {
Icon(Icons.Filled.Lock, null, tint = color, modifier = Modifier.size(28.dp))
// shackle redrawn on top so it can lift independently
Canvas(Modifier.size(28.dp)) {
translate(top = lift.dp.toPx()) {
rotate(rot, pivot = Offset(size.width * 0.32f, size.height * 0.42f)) {
drawArc(color, 180f, 180f, false,
topLeft = Offset(size.width * 0.32f, size.height * 0.18f),
size = Size(size.width * 0.36f, size.height * 0.36f),
style = Stroke(2.5.dp.toPx(), cap = StrokeCap.Round))
}
}
}
}
}