Icons
Iconsanimated

QR scan

A QR frame with a laser line sweeping top to bottom as it scans for a code.

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 QrScan() {
    val y by rememberInfiniteTransition(label = "qr").animateFloat(
        0f, 1f, infiniteRepeatable(tween(1400, easing = EaseInOut), RepeatMode.Reverse), label = "y")
    val color = MaterialTheme.colorScheme.primary
    Canvas(Modifier.size(40.dp)) {
        val c = 6.dp.toPx()
        listOf(0f to 0f, size.width to 0f, 0f to size.height, size.width to size.height).forEach { (x, yy) ->
            val sx = if (x == 0f) 1 else -1; val sy = if (yy == 0f) 1 else -1
            drawLine(color, Offset(x, yy), Offset(x + sx * c, yy), 3f); drawLine(color, Offset(x, yy), Offset(x, yy + sy * c), 3f)
        }
        drawLine(color, Offset(4f, size.height * y), Offset(size.width - 4f, size.height * y), 2.dp.toPx(), StrokeCap.Round)
    }
}