KwikRatingBar

fun KwikRatingBar(modifier: Modifier = Modifier, rating: Double = 0.0, stars: Int = 5, starsColor: Color = KwikColorYellow, starSize: Dp = 24.dp, spacing: Dp = 2.dp, showBadge: Boolean = true, badgeContainerColor: Color = determineRatingColor(rating), badgeContentColor: Color = Color.DarkGray, clickable: Boolean = false, onClick: (Int) -> Unit = {})

A rating bar that displays and optionally allows setting a rating using stars.

Parameters

modifier

The modifier to apply to this layout.

rating

The initial rating to display (0.0 when clickable mode is enabled).

stars

The total number of stars to display.

starsColor

The color of the filled stars.

starSize

The size of each star icon.

spacing

The spacing between stars.

showBadge

Whether to show a badge displaying the numerical rating.

badgeContainerColor

The background color of the badge, determined by rating by default.

badgeContentColor

The text color of the badge.

clickable

Whether stars can be clicked to set a rating.

onClick

Callback function that receives the selected rating (1-5) when a star is clicked.

Example usage:

Display-only mode:

KwikRatingBar(
stars = 5,
rating = 4.5,
showBadge = true
)

Clickable mode:

var userRating by remember { mutableStateOf(0) }
KwikRatingBar(
stars = 5,
rating = userRating.toDouble(),
clickable = true,
onClick = { selectedRating ->
userRating = selectedRating
}
)