Staaarter

Product Reviews Section

A rating summary with a per-star distribution chart, plus a review list with working helpful votes and a load more toggle. Built for a product page's reviews tab.

By Staaarter Team
Ecommerce
Docs
Live preview

Docs

Installation

A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button, badge, avatar, avatar-initials dependencies and any missing npm packages, and installs them straight into your project.

npx shadcn add https://staaarter.com/r/product-reviews-section.json

Prefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/ecommerce/ecommerce11.tsx instead.

Usage

The file also exports ecommerce11Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.

import { Ecommerce11, ecommerce11Demo } from "@/components/blocks/ecommerce/ecommerce11";

export default function Page() {
  return <Ecommerce11 {...ecommerce11Demo} />;
}

Props

PropTypeDefaultDescription
headingstring"Customer reviews"Heading above the rating summary.
averageRatingnumbernoneAverage rating, e.g. 4.6, shown large and rounded to one decimal.
reviewCountnumbernoneTotal review count shown under the average rating.
distributionRatingDistributionRow[][]Percentage bars from 5 stars down to 1 star.
reviewsReview[]noneReviews shown immediately.
moreReviewsReview[][]Additional reviews revealed by the Load more button.
classNamestringnoneExtra classes for the outer section element.

Types

type RatingDistributionRow = {
  stars: 5 | 4 | 3 | 2 | 1;
  percentage: number; // 0-100, rendered as the bar's fill width
};

type Review = {
  id: string;
  name: string;
  avatar?: { src: string; alt: string };
  verified?: boolean;
  rating: number;
  date: string; // pre-formatted, e.g. "July 18, 2026"
  text: string;
  helpfulCount: number; // initial count before any local Helpful clicks
};

Behavior notes

  • The Helpful button is genuinely functional: clicking it increments that review's counter in local useState, seeded from each review's helpfulCount prop. It resets on remount, nothing is persisted.
  • Load more reveals the fixed moreReviews list via a real useState toggle, not a fetch; the button disappears once clicked or is never shown if moreReviews is empty.
  • The distribution bars and star icons are static visuals rendered from the distribution/rating props; there is no interactive filtering by star count.
  • A review without an avatar prop falls back to initials built from its name, same pattern as the About blocks.