Cards
Cardsanimated

Count Up Stat

A headline number animates upward from zero with a delta chip.

Total Revenue
$12,480
+12.4%

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 CountUpStatCard() {
  val target = 12480
  val progress = remember { Animatable(0f) }
  LaunchedEffect(Unit) {
    progress.animateTo(
      targetValue = 1f,
      animationSpec = tween(1200, easing = FastOutSlowInEasing),
    )
  }
  val value = (target * progress.value).toInt()
  ElevatedCard(
    shape = RoundedCornerShape(20.dp),
    modifier = Modifier.width(260.dp),
  ) {
    Column(Modifier.padding(20.dp)) {
      Text(
        text = "Total Revenue",
        style = MaterialTheme.typography.labelMedium,
        color = MaterialTheme.colorScheme.onSurfaceVariant,
      )
      Spacer(Modifier.height(6.dp))
      Text(
        text = "$" + "%,d".format(value),
        style = MaterialTheme.typography.headlineMedium,
        fontWeight = FontWeight.Bold,
      )
      Spacer(Modifier.height(8.dp))
      Surface(
        shape = RoundedCornerShape(50),
        color = Color(0xFF10B981).copy(alpha = 0.15f),
      ) {
        Text(
          text = "+12.4%",
          color = Color(0xFF10B981),
          style = MaterialTheme.typography.labelSmall,
          modifier = Modifier.padding(
            horizontal = 8.dp,
            vertical = 3.dp,
          ),
        )
      }
    }
  }
}