Loaders
Loadersanimated

Gauge meter

A semicircular gauge whose needle sweeps back and forth across the dial.

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 = "meter")
val angle by t.animateFloat(
    initialValue = -80f,
    targetValue = 80f,
    animationSpec = infiniteRepeatable(
        tween(1200, easing = FastOutSlowInEasing),
        RepeatMode.Reverse,
    ),
    label = "angle",
)
val primary = MaterialTheme.colorScheme.primary
val track = MaterialTheme.colorScheme.surfaceVariant
Canvas(Modifier.size(width = 44.dp, height = 26.dp)) {
    val pivot = Offset(size.width / 2f, size.height)
    drawArc(
        color = track,
        startAngle = 180f,
        sweepAngle = 180f,
        useCenter = false,
        style = Stroke(width = 3.dp.toPx(), cap = StrokeCap.Round),
    )
    rotate(angle, pivot = pivot) {
        drawLine(
            color = primary,
            start = pivot,
            end = Offset(pivot.x, pivot.y - size.height * 0.8f),
            strokeWidth = 2.5.dp.toPx(),
            cap = StrokeCap.Round,
        )
    }
}