Back to Woocommerce

README

packages/js/components/src/rating/README.md

10.8.0-dev1.5 KB
Original Source

Rating

Use Rating to display a set of stars, filled, empty or half-filled, that represents a rating in a scale between 0 and the prop totalStars (default 5).

Usage

jsx
<Rating rating={ 2.5 } totalStars={ 6 } />

Props

NameTypeDefaultDescription
ratingNumber0Number of stars that should be filled. You can pass a partial number of stars like 2.5
totalStarsNumber5The total number of stars the rating is out of
sizeNumber18The size in pixels the stars should be rendered at
classNameStringnullAdditional CSS classes

ProductRating

Display a set of stars representing the product's average rating.

Usage

jsx
// Use a real WooCommerce Product here.
const product = { average_rating: 3.5 };

<ProductRating product={ product } />

Props

NameTypeDefaultDescription
productObjectnull(required) A product object containing a average_rating. See https://woocommerce.github.io/woocommerce-rest-api-docs/#products

ReviewRating

Display a set of stars representing the review's rating.

Usage

jsx
// Use a real WooCommerce Review here.
const review = { rating: 5 };

<ReviewRating review={ review } />

Props

NameTypeDefaultDescription
reviewObjectnull(required) A review object containing a rating. See https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-product-reviews