Cards
Cardsanimated

Stock Countdown

Low-stock card with a ticking countdown timer and depleting bar.

Selling fast
Only 3 left in stock
Ends in 02:14:07

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 StockCountdownCard() {
  var left by remember { mutableStateOf(7) }
  LaunchedEffect(Unit) {
    while (left > 0) { delay(1000); left-- }
  }
  val progress by animateFloatAsState(left / 10f, label = "p")
  Card(
    modifier = Modifier.width(240.dp),
    shape = RoundedCornerShape(18.dp)
  ) {
    Column(Modifier.padding(16.dp)) {
      Box(
        Modifier
          .fillMaxWidth()
          .height(110.dp)
          .clip(RoundedCornerShape(12.dp))
          .background(MaterialTheme.colorScheme.surfaceVariant)
      )
      Spacer(Modifier.height(10.dp))
      Row(verticalAlignment = Alignment.CenterVertically) {
        Icon(Icons.Default.Timer, null, modifier = Modifier.size(16.dp))
        Text("  Only $left left!",
          style = MaterialTheme.typography.labelLarge)
      }
      Spacer(Modifier.height(8.dp))
      LinearProgressIndicator(
        progress = { progress },
        modifier = Modifier.fillMaxWidth()
      )
    }
  }
}