Cards
Cardsanimated

Sparkline Trend

A compact trend line draws itself across a labelled metric value.

Active Users
8,932

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 SparklineTrendCard() {
  val pts = listOf(0.3f, 0.5f, 0.4f, 0.7f, 0.6f, 0.85f, 0.9f)
  val draw = remember { Animatable(0f) }
  LaunchedEffect(Unit) {
    draw.animateTo(1f, tween(1100, easing = LinearEasing))
  }
  OutlinedCard(
    shape = RoundedCornerShape(18.dp),
    modifier = Modifier.width(260.dp),
  ) {
    Column(Modifier.padding(18.dp)) {
      Text(
        text = "Active Users",
        style = MaterialTheme.typography.labelMedium,
        color = MaterialTheme.colorScheme.onSurfaceVariant,
      )
      Text(
        text = "8,932",
        style = MaterialTheme.typography.headlineSmall,
        fontWeight = FontWeight.Bold,
      )
      Spacer(Modifier.height(10.dp))
      Canvas(
        Modifier
          .fillMaxWidth()
          .height(48.dp),
      ) {
        val step = size.width / (pts.size - 1)
        val path = Path()
        pts.forEachIndexed { i, p ->
          val x = i * step
          val y = size.height * (1f - p)
          if (i == 0) path.moveTo(x, y) else path.lineTo(x, y)
        }
        val measure = PathMeasure()
        measure.setPath(path, false)
        val seg = Path()
        measure.getSegment(
          0f,
          measure.length * draw.value,
          seg,
          true,
        )
        drawPath(
          path = seg,
          color = Color(0xFF6366F1),
          style = Stroke(width = 3.dp.toPx()),
        )
      }
    }
  }
}