Rating

fun Rating(@FloatRange(from = 0.0, to = 5.0) value: Float, contentDescription: String?, modifier: Modifier = Modifier, ratingLabel: String? = null, quantityLabel: String? = null, size: RatingSize = RatingSize.Regular, onClick: () -> Unit? = null)

Rating component is used to display a star rating with average value and number of reviews/ratings for a product.

Parameters

value

Rating values from 0.0-5.0 which will be represented with star icons (filled, half-filled and empty)

contentDescription

Used for localized content description.

modifier

Default modifier for this component.

ratingLabel

Trailing label for this component. Used to specify average rating value.

quantityLabel

Trailing label for this component. Used to specify number if ratings/reviews.

size

Used for stars and font sizes. Regular is default

onClick

Click action for the whole component.

See also

Samples

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.tooling.preview.Preview
import net.ikea.skapa.foundation.*
import net.ikea.skapa.ui.components.Rating
import net.ikea.skapa.ui.components.RatingSize

fun main() { 
   //sampleStart 
   SkapaThemeM3(darkTheme = isSystemInDarkTheme()) {
    Column {
        Rating(
            value = 3.70f,
            quantityLabel = "Not Clickable",
            contentDescription = "Customer ratings: three and a half stars, from 25 ratings"
        )

        Rating(
            value = 3f,
            ratingLabel = "3.0",
            quantityLabel = "Clickable",
            size = RatingSize.Small,
            contentDescription = "Customer ratings: three and a half stars, from 25 ratings"
        ) {
            /* Do something */
        }
    }
} 
   //sampleEnd
}