Rating and stars
zb:shop.rating shows a product's stars, score and number of reviews, and zb:shop.stars only the stars.
zb:shop.rating · zb:shop.stars zubazar/ui-pro
This component is in Zubazar UI Pro; Zubazar UI Pro brings Zubazar UI with it. Installing Zubazar UI Pro →
On a card
BLADE
The default small size shows the stars, the score and the number of reviews in brackets.
<zb:shop.rating :product="$product" />
On the product page
BLADE
size="md" draws larger stars and "312 reviews"; the product page's title and its reviews tab use it.
<zb:shop.rating :product="$product" size="md" />
Star sizes
BLADE
Pick the size of zb:shop.stars with size; the score is rounded to the nearest whole star (3.6 → 4).
<div class="flex flex-col gap-3">
<zb:shop.stars :value="4" size="sm" />
<zb:shop.stars :value="4" />
<zb:shop.stars :value="4" size="lg" />
</div>
| Prop | Values |
|---|---|
size | sm · md (default) · lg |
max | The number of stars; default 5 |
In a customer review
BLADE
Show a review's score with small stars; label changes what screen readers hear.
<article class="max-w-md rounded-sm bg-surface p-5 shadow-card">
<div class="flex items-center justify-between gap-3">
<p class="text-sm font-semibold text-ink">{{ $review['name'] }}</p>
<zb:shop.stars :value="$review['rating']" size="sm" :label="$review['rating'].' out of 5 stars'" />
</div>
<p class="mt-3 text-sm text-body">{{ $review['text'] }}</p>
</article>
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
rating: product | — | — | zb:shop.rating: the product whose score (rating) and number of reviews (reviews) are shown; required |
rating: size | — | sm | sm: a card, the score and a short count · md: the product page, "312 reviews" |
stars: value | number | 0 | zb:shop.stars: the score; rounded to the nearest whole star |
stars: max | number | 5 | The number of stars |
stars: size | — | md | sm · md · lg |
stars: label | — | null | What screen readers hear; "4 / 5" when left out |
Developer notes
- Both are read-only;
zb:shop.ratingis for the product card and the product page,zb:shop.starsfor scores that are not a product's, such as customer reviews. - Screen readers read the number of reviews as "312 reviews"; in narrow cards the number wraps under the stars.
- There are no half stars.