Cards
Cardsanimated

Speedometer Gauge

A half-circle gauge needle sweeps to indicate a performance score.

Performance
82

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 SpeedometerGaugeCard() {
  val sweep = remember { Animatable(0f) }
  LaunchedEffect(Unit) {
    sweep.animateTo(0.82f, tween(1200, easing = FastOutSlowInEasing))
  }
  Card(
    shape = RoundedCornerShape(20.dp),
    modifier = Modifier.width(260.dp),
  ) {
    Column(
      Modifier
        .padding(20.dp)
        .fillMaxWidth(),
      horizontalAlignment = Alignment.CenterHorizontally,
    ) {
      Text(
        text = "Performance",
        style = MaterialTheme.typography.labelMedium,
        color = MaterialTheme.colorScheme.onSurfaceVariant,
      )
      Spacer(Modifier.height(8.dp))
      Canvas(
        Modifier
          .width(140.dp)
          .height(72.dp),
      ) {
        drawArc(
          color = Color(0xFF334155).copy(alpha = 0.2f),
          startAngle = 180f,
          sweepAngle = 180f,
          useCenter = false,
          style = Stroke(10.dp.toPx(), cap = StrokeCap.Round),
        )
        drawArc(
          color = Color(0xFF22C55E),
          startAngle = 180f,
          sweepAngle = 180f * sweep.value,
          useCenter = false,
          style = Stroke(10.dp.toPx(), cap = StrokeCap.Round),
        )
      }
      Text(
        text = "${(sweep.value * 100).toInt()}",
        style = MaterialTheme.typography.headlineMedium,
        fontWeight = FontWeight.Bold,
      )
    }
  }
}