Cards
Cardsanimated

Rating Distribution

Reviews card with average score and animated five-star histogram bars.

4.6

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 RatingDistributionCard() {
  val bars = listOf(0.7f, 0.5f, 0.2f, 0.1f, 0.05f)
  Card(
    modifier = Modifier.width(260.dp),
    shape = RoundedCornerShape(18.dp)
  ) {
    Row(Modifier.padding(16.dp)) {
      Column(horizontalAlignment = Alignment.CenterHorizontally) {
        Text("4.6", style = MaterialTheme.typography.displaySmall)
        Row {
          repeat(5) {
            Icon(Icons.Default.Star, null,
              modifier = Modifier.size(12.dp))
          }
        }
      }
      Spacer(Modifier.width(16.dp))
      Column(Modifier.weight(1f)) {
        bars.forEachIndexed { i, frac ->
          val w by animateFloatAsState(frac, tween(600), label = "b$i")
          Row(verticalAlignment = Alignment.CenterVertically) {
            Text("${'$'}{5 - i}",
              style = MaterialTheme.typography.labelSmall)
            Spacer(Modifier.width(6.dp))
            LinearProgressIndicator(
              progress = { w },
              modifier = Modifier.weight(1f).height(6.dp)
            )
          }
        }
      }
    }
  }
}