Product Image Gallery
Main image with a thumbnail strip built as a real tablist, so arrow keys work and the ratio is fixed to stop the buy box shifting.
Average rating with a clickable histogram — because a 4.3 of forties and fives is a different product from a 4.3 of ones and fives.
components/product-review-summary.tsxnpx hoverlab add product-review-summary
Or over MCP, from your editor's agent — no account needed.
Free to read, copy and install, for personal and non-commercial projects. Shipping it in client work or a paid product needs Pro ($79 once). The source lands in your repo and stops being ours — no attribution, nothing to upgrade.
Start a page with this section — add more, order them, and leave with the page source.
4.5/5
218 reviews
94% would recommend
Rendered live in your current theme — this is the same component whose source is below, not a screenshot of it.
/**
* <ProductReviewSummary> — average rating and a distribution histogram.
*
* The distribution is the point. An average of 4.3 made of forties and
* fives is a different product from a 4.3 made of ones and fives, and the
* bar chart is the only way a customer can tell them apart at a glance.
*
* Each bar is a real link to the filtered review list — a histogram you
* cannot click is a picture of information rather than a way in.
*
* The bars are `aria-hidden` and the same data is exposed as a plain list
* to assistive tech: five bars of varying width announce as nothing useful,
* where "5 stars, 148 reviews, 68 percent" does.
*
* Server component.
*/
import * as React from 'react'
import { Star } from 'lucide-react'
export interface ProductReviewSummaryProps {
/** Count of reviews at each star level, index 0 = 1 star. */
distribution?: [number, number, number, number, number]
recommendPercent?: number
className?: string
}
const DEFAULT_DISTRIBUTION: [number, number, number, number, number] = [3, 5, 14, 48, 148]
export function ProductReviewSummary({
distribution = DEFAULT_DISTRIBUTION,
recommendPercent = 94,
className = '',
}: ProductReviewSummaryProps) {
const total = distribution.reduce((n, count) => n + count, 0)
// Weighted mean. Guarded against a product with no reviews yet, where
// the naive version divides by zero and renders "NaN out of 5".
const average =
total === 0
? 0
: distribution.reduce((sum, count, i) => sum + count * (i + 1), 0) / total
return (
<section
className={`rounded-2xl border border-border/60 bg-card/60 p-6 ${className}`}
>
<div className="grid gap-6 sm:grid-cols-[auto_1fr] sm:gap-10">
{/* Headline */}
<div className="text-center sm:text-start">
<p className="text-4xl font-extrabold tracking-tight">
{average.toFixed(1)}
<span className="text-lg font-medium text-muted-foreground">/5</span>
</p>
<div className="mt-1.5 flex justify-center gap-0.5 sm:justify-start">
{Array.from({ length: 5 }, (_, i) => (
<Star
key={i}
aria-hidden
className={
i < Math.round(average)
? 'h-4 w-4 fill-amber-400 text-amber-400'
: 'h-4 w-4 text-muted-foreground/30'
}
/>
))}
</div>
<p className="mt-2 text-sm text-muted-foreground">
{total.toLocaleString('en-GB')} {total === 1 ? 'review' : 'reviews'}
</p>
{recommendPercent ? (
<p className="mt-1 text-sm font-medium text-emerald-600 dark:text-emerald-400">
{recommendPercent}% would recommend
</p>
) : null}
</div>
{/* Histogram — decorative; the real data is the list below. */}
<div aria-hidden className="space-y-1.5">
{[5, 4, 3, 2, 1].map((stars) => {
const count = distribution[stars - 1]
const percent = total === 0 ? 0 : (count / total) * 100
return (
<a
key={stars}
href={`#reviews?rating=${stars}`}
className="group flex items-center gap-3 text-sm"
>
<span className="w-10 shrink-0 text-muted-foreground">{stars} ★</span>
<span className="h-2 flex-1 overflow-hidden rounded-full bg-muted">
<span
className="block h-full rounded-full bg-amber-400 transition-all group-hover:bg-amber-500 border border-transparent"
style={{ width: `${percent}%` }}
/>
</span>
<span className="min-w-10 shrink-0 text-end tabular-nums text-muted-foreground">
{count}
</span>
</a>
)
})}
</div>
</div>
{/* The same figures, as something a screen reader can actually use. */}
<ul className="sr-only">
{[5, 4, 3, 2, 1].map((stars) => {
const count = distribution[stars - 1]
const percent = total === 0 ? 0 : Math.round((count / total) * 100)
return (
<li key={stars}>
{stars} stars: {count} reviews, {percent} percent
</li>
)
})}
</ul>
</section>
)
}
bg-card, text-muted-foreground) — it inherits your theme instead of overriding it.Drop it at components/product-review-summary.tsx and import it where you need the section:
import { ProductReviewSummary } from '@/components/product-review-summary'1 of this block’s props are simple enough to drive from here. Change them and the block below re-renders — it is the same component whose source is above, not a mock of it. Everything else it accepts is in the table underneath.
Read out of the component’s own type and signature, so this cannot drift from the source below. Every prop has a default — the component renders standalone before you pass it anything.
| Prop | Type | Default |
|---|---|---|
distributionCount of reviews at each star level, index 0 = 1 star. | [number, number, number, number, number] | DEFAULT_DISTRIBUTION |
recommendPercent | number | 94 |
className | string | '' |
The same block rendered once to markup, wrapped as a file your framework compiles. Tailwind classes are framework-agnostic, so the design transfers intact — the behaviour does not.
<!--
Rating Distribution Summary — markup from the Hoverlab catalog.
This is the block rendered once to HTML and wrapped as a component
file. It is not a port of the React source: the Tailwind classes carry
the design, which is the part that took the work, and they are the same
in every framework.
This block has no interactive behaviour, so nothing is missing.
-->
<section class="rounded-2xl border border-border/60 bg-card/60 p-6 ">
<div class="grid gap-6 sm:grid-cols-[auto_1fr] sm:gap-10">
<div class="text-center sm:text-start">
<p class="text-4xl font-extrabold tracking-tight">4.5<span class="text-lg font-medium text-muted-foreground">/5</span></p>
<div class="mt-1.5 flex justify-center gap-0.5 sm:justify-start">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-star h-4 w-4 fill-amber-400 text-amber-400" aria-hidden="true">
<path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"></path>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-star h-4 w-4 fill-amber-400 text-amber-400" aria-hidden="true">
<path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"></path>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-star h-4 w-4 fill-amber-400 text-amber-400" aria-hidden="true">
<path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"></path>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-star h-4 w-4 fill-amber-400 text-amber-400" aria-hidden="true">
<path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"></path>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-star h-4 w-4 fill-amber-400 text-amber-400" aria-hidden="true">
<path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"></path>
</svg>
</div>
<p class="mt-2 text-sm text-muted-foreground">218 reviews</p>
<p class="mt-1 text-sm font-medium text-emerald-600 dark:text-emerald-400">94% would recommend</p>
</div>
<div aria-hidden="true" class="space-y-1.5">
<a href="#reviews?rating=5" class="group flex items-center gap-3 text-sm">
<span class="w-10 shrink-0 text-muted-foreground">5 ★</span>
<span class="h-2 flex-1 overflow-hidden rounded-full bg-muted">
<span class="block h-full rounded-full bg-amber-400 transition-all group-hover:bg-amber-500 border border-transparent" style="width:67.88990825688074%"></span>
</span>
<span class="min-w-10 shrink-0 text-end tabular-nums text-muted-foreground">148</span>
</a>
<a href="#reviews?rating=4" class="group flex items-center gap-3 text-sm">
<span class="w-10 shrink-0 text-muted-foreground">4 ★</span>
<span class="h-2 flex-1 overflow-hidden rounded-full bg-muted">
<span class="block h-full rounded-full bg-amber-400 transition-all group-hover:bg-amber-500 border border-transparent" style="width:22.018348623853214%"></span>
</span>
<span class="min-w-10 shrink-0 text-end tabular-nums text-muted-foreground">48</span>
</a>
<a href="#reviews?rating=3" class="group flex items-center gap-3 text-sm">
<span class="w-10 shrink-0 text-muted-foreground">3 ★</span>
<span class="h-2 flex-1 overflow-hidden rounded-full bg-muted">
<span class="block h-full rounded-full bg-amber-400 transition-all group-hover:bg-amber-500 border border-transparent" style="width:6.422018348623854%"></span>
</span>
<span class="min-w-10 shrink-0 text-end tabular-nums text-muted-foreground">14</span>
</a>
<a href="#reviews?rating=2" class="group flex items-center gap-3 text-sm">
<span class="w-10 shrink-0 text-muted-foreground">2 ★</span>
<span class="h-2 flex-1 overflow-hidden rounded-full bg-muted">
<span class="block h-full rounded-full bg-amber-400 transition-all group-hover:bg-amber-500 border border-transparent" style="width:2.293577981651376%"></span>
</span>
<span class="min-w-10 shrink-0 text-end tabular-nums text-muted-foreground">5</span>
</a>
<a href="#reviews?rating=1" class="group flex items-center gap-3 text-sm">
<span class="w-10 shrink-0 text-muted-foreground">1 ★</span>
<span class="h-2 flex-1 overflow-hidden rounded-full bg-muted">
<span class="block h-full rounded-full bg-amber-400 transition-all group-hover:bg-amber-500 border border-transparent" style="width:1.3761467889908259%"></span>
</span>
<span class="min-w-10 shrink-0 text-end tabular-nums text-muted-foreground">3</span>
</a>
</div>
</div>
<ul class="sr-only">
<li>5 stars: 148 reviews, 68 percent</li>
<li>4 stars: 48 reviews, 22 percent</li>
<li>3 stars: 14 reviews, 6 percent</li>
<li>2 stars: 5 reviews, 2 percent</li>
<li>1 stars: 3 reviews, 1 percent</li>
</ul>
</section>
What each framework gets across the whole catalog — effects convert properly; this rung is markup.
The component, its props, the design tokens it expects and the command that installs it — as one prompt. Paste it into Claude, Cursor, v0 or ChatGPT and what they build around it will match the rest of the catalog instead of inventing its own system.
Want the whole screen instead of this one section? Open a page and copy it entire.
All of them free to read, copy and install — no account, no locked tiles, no watermarked preview. The whole catalog is open, and so are the API and the CLI.
Browse Product DetailCopying the code is free. Putting it in client work or a paid product is what Pro is for — the licence, not the access.
Main image with a thumbnail strip built as a real tablist, so arrow keys work and the ratio is fixed to stop the buy box shifting.
Price, variant radiogroup, quantity stepper and add-to-bag — with sold-out sizes disabled and visible rather than hidden.
Description, materials, delivery and returns in named <details> elements — no JavaScript, and the copy stays indexable while collapsed.
The panel that decides whether the parcel comes back: what the model is wearing and what previous buyers did, above a table whose inches are converted rather than maintained twice.
The specification table beside the product image, with the two or three figures that decide the purchase pulled out of it.
The capture that replaces a dead sold-out button, with the honest caveat that a notification is not a reservation.