Cards
Cardsanimated

Net Worth Trend

Net worth card with an area sparkline filling beneath an animated trend line.

Net Worth
$148,920

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 NetWorthTrendCard() {
  val pts = listOf(0.3f, 0.45f, 0.4f, 0.6f, 0.7f, 0.85f)
  val grow = remember { Animatable(0f) }
  LaunchedEffect(Unit) { grow.animateTo(1f, tween(1100)) }
  val accent = MaterialTheme.colorScheme.primary
  ElevatedCard(
    modifier = Modifier.fillMaxWidth().padding(16.dp),
    shape = RoundedCornerShape(20.dp)
  ) {
    Column(Modifier.padding(18.dp)) {
      Text("Net Worth",
        style = MaterialTheme.typography.labelMedium)
      Text("$148,920",
        style = MaterialTheme.typography.headlineSmall,
        fontWeight = FontWeight.Bold)
      Spacer(Modifier.height(12.dp))
      Canvas(Modifier.fillMaxWidth().height(64.dp)) {
        val step = size.width / (pts.size - 1)
        val line = Path()
        pts.forEachIndexed { i, v ->
          val x = i * step; val y = size.height * (1 - v)
          if (i == 0) line.moveTo(x, y) else line.lineTo(x, y)
        }
        val area = Path().apply {
          addPath(line)
          lineTo(size.width, size.height)
          lineTo(0f, size.height); close()
        }
        clipRect(right = size.width * grow.value) {
          drawPath(area, Brush.verticalGradient(
            listOf(accent.copy(alpha = 0.35f), Color.Transparent)))
          drawPath(line, accent,
            style = Stroke(4f, cap = StrokeCap.Round))
        }
      }
    }
  }
}