v0.0.2
Demos (demo panel, opens in a new tab)

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

PRO

This component is in Zubazar UI Pro; Zubazar UI Pro brings Zubazar UI with it. Installing Zubazar UI Pro →

On a card

On a card: view
BLADE

The default small size shows the stars, the score and the number of reviews in brackets.

blade
<zb:shop.rating :product="$product" />

On the product page

On the product page: view
BLADE

size="md" draws larger stars and "312 reviews"; the product page's title and its reviews tab use it.

blade
<zb:shop.rating :product="$product" size="md" />

Star sizes

Star sizes: view
BLADE

Pick the size of zb:shop.stars with size; the score is rounded to the nearest whole star (3.6 → 4).

blade
<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>
PropValues
sizesm · md (default) · lg
maxThe number of stars; default 5

In a customer review

In a customer review: view
BLADE

Show a review's score with small stars; label changes what screen readers hear.

blade
<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?

PropTypeDefaultDescription
rating: product— — zb:shop.rating: the product whose score (rating) and number of reviews (reviews) are shown; required
rating: size—smsm: a card, the score and a short count · md: the product page, "312 reviews"
stars: valuenumber0zb:shop.stars: the score; rounded to the nearest whole star
stars: maxnumber5The number of stars
stars: size—mdsm · md · lg
stars: label—nullWhat screen readers hear; "4 / 5" when left out

Developer notes

Events, hooks and details
  • Both are read-only; zb:shop.rating is for the product card and the product page, zb:shop.stars for 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.
Zubazar UI · ZubazarDesigned for people.