Cards
Cardsanimated

Sleep Stages

Stacked nightly sleep stages with a soft hypnogram wave for deep rest.

Sleep · 7h 24m
Deep 1hREM 2hLight 4h

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 SleepStagesCard() {
  val t = rememberInfiniteTransition(label = "sleep")
  val shift by t.animateFloat(
    0f, 6.28f,
    infiniteRepeatable(tween(6000, easing = LinearEasing)),
    label = "shift"
  )
  OutlinedCard(Modifier.fillMaxWidth()) {
    Column(Modifier.padding(20.dp)) {
      Text(
        "Sleep · 7h 24m",
        style = MaterialTheme.typography.titleMedium
      )
      Spacer(Modifier.height(14.dp))
      Canvas(Modifier.fillMaxWidth().height(70.dp)) {
        val w = size.width; val h = size.height
        val path = Path()
        val n = 80
        for (i in 0..n) {
          val x = w * i / n
          val y = h / 2 +
            sin(i / 6f + shift) * h * 0.3f
          if (i == 0) path.moveTo(x, y)
          else path.lineTo(x, y)
        }
        drawPath(
          path, Color(0xFF5E5CE6),
          style = Stroke(3f, cap = StrokeCap.Round)
        )
      }
      Spacer(Modifier.height(12.dp))
      Row(
        Modifier.fillMaxWidth(),
        horizontalArrangement = Arrangement.SpaceBetween
      ) {
        Text("Deep 1h", style =
          MaterialTheme.typography.labelSmall)
        Text("REM 2h", style =
          MaterialTheme.typography.labelSmall)
        Text("Light 4h", style =
          MaterialTheme.typography.labelSmall)
      }
    }
  }
}