Feedback
Feedbackanimated

Rating prompt

A satisfaction card that fills the star row up to the hovered position.

How was your experience?

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 RatingPrompt(onRate: (Int) -> Unit) {
    var rating by remember { mutableStateOf(0) }
    Surface(shape = MaterialTheme.shapes.large, tonalElevation = 1.dp) {
        Column(
            Modifier.padding(16.dp),
            horizontalAlignment = Alignment.CenterHorizontally,
        ) {
            Text("How was your experience?",
                style = MaterialTheme.typography.titleSmall)
            Row(Modifier.padding(top = 10.dp)) {
                (1..5).forEach { i ->
                    IconButton(onClick = { rating = i; onRate(i) }) {
                        Icon(
                            if (i <= rating) Icons.Filled.Star
                            else Icons.Filled.StarBorder,
                            contentDescription = "$i stars",
                            tint = Color(0xFFF59E0B),
                        )
                    }
                }
            }
        }
    }
}