Cards
Cardsanimated

Flash Sale Timer

Flash-sale card with a live countdown in hours minutes and seconds.

Flash sale
021147

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 FlashSaleTimerCard() {
  var secs by remember { mutableStateOf(3 * 3600 + 25 * 60 + 9) }
  LaunchedEffect(Unit) {
    while (secs > 0) { delay(1000); secs-- }
  }
  val h = secs / 3600; val m = (secs % 3600) / 60; val s = secs % 60
  Card(
    modifier = Modifier.width(260.dp),
    shape = RoundedCornerShape(18.dp)
  ) {
    Column(Modifier.padding(16.dp)) {
      Row(verticalAlignment = Alignment.CenterVertically) {
        Icon(Icons.Default.Bolt, null,
          tint = MaterialTheme.colorScheme.error)
        Text("  Flash Sale",
          style = MaterialTheme.typography.titleMedium)
      }
      Spacer(Modifier.height(12.dp))
      Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
        listOf(h, m, s).forEach { v ->
          Surface(
            color = MaterialTheme.colorScheme.surfaceVariant,
            shape = RoundedCornerShape(10.dp)
          ) {
            Text("%02d".format(v),
              Modifier.padding(horizontal = 12.dp, vertical = 8.dp),
              style = MaterialTheme.typography.titleLarge)
          }
        }
      }
    }
  }
}