shadcn.io is not affiliated with official shadcn/ui
Rating Breakdown Testimonials Block for React
A review summary whose histogram rows are filter buttons: press a star row and the featured reviews narrow to that rating, with a live count and an empty state.
Installation
Overview
A score you can interrogate. A compact header sits above a band between the page's rails, split by one shared hairline. On one side, the average with its stars, the review count and a five-row breakdown; on the other, a status line over a ruled list of four featured reviews, each with its stars and reviewer beside the quote, and a Shine Button, the block's one primary control, to write a new review. Every row of the breakdown is a toggle button: press the four-star row and only the four-star reviews stay, press the five-star row as well and both sets show. The status line says what you are looking at ("2 featured reviews with 4 stars"), and when no featured review matches, an empty state offers a way back. Stars, bars and the pressed ring are foreground tones, so the Shine Button is the only primary element. The average, every percentage and the star fill are worked out from the review counts in the file. It's built from Toggle, Progress, Avatar, Empty, Guides and Shine Button, with Lucide stars, CSS transitions only and your theme's tokens. For product pages, marketplace listings and anywhere the shape of the reviews matters as much as the average.
FAQ
How do I use my own numbers and reviews?
Edit COUNTS at the top of the file: the number of reviews at five, four, three, two and one star, in that order. The total, the average (to one decimal, by integer maths), the star fill and every row's percentage are derived from it. Then replace REVIEWS with the reviews you want to feature, each with a stars value. Only put real review numbers here.
What does the filter act on?
The breakdown counts every review, but the list below shows a handful of featured ones, so the filter narrows that handful. The status line says "featured reviews" for that reason, and a row with no featured review shows the empty state instead of an empty list. If you render all your reviews, the same rows work as a full filter.
Why do the percentages always add up to 100?
Rounding each row separately can total 99 or 101. The block gives every row its rounded-down share, then hands the leftover points to the rows with the biggest remainders, so the bars and labels always add up to exactly 100.
How does it work with a keyboard and a screen reader?
Each row is a toggle button in the tab order, pressed with Space or Enter, and it is announced with its state, for example "5 stars: 236 reviews, 57%, pressed". The bars and the visible numbers are hidden from assistive technology so nothing is read twice. After every press a polite status line reads out the result, and "Clear filters" returns focus to the first row.
Related
- Pro
Star Distribution Testimonials
Ratings and reviewsA vertical column histogram of one-to-five star reviews in one framed figure whose cells share hairlines: the score and a plain-words verdict, one owner's quote, and the chart with the value above each column and a dashed average marker. A Shine Button in the header links to the reviews.
- Pro
Progress Bar Testimonials
Results and figuresA customer survey as one hairline band: an overall score and five categories as bars out of 100, each with a tick at the industry average and a badge for the gap, above two customer quotes.
- Pro
Top Rated Testimonials
Ratings and reviewsFour reviews of an operations app with a sort control in the header: most helpful, highest rated or newest, re-ordered live from typed numbers, in one band of ruled rows with a status line and an average.
- Pro
With Rating Testimonials
Collect a reviewOne large customer quote over a closing band you can rate in: choose stars and the average and the rating count change on the spot, with a note that nothing is saved.
- Pro
Verified Buyer Testimonials
Ratings and reviewsOne focal review under a Verified purchase badge in a raised card inside a tinted shell, a divider and a receipt of what the customer bought, then a band of three compact reviews with the same badge.
- Pro
Inset Star Rating Big CTA
Social proofA card-in-card call to action built on a rating summary: a headline and a Shine Button over a band with a big score and foreground stars beside a five-to-one star histogram, all figures worked out from the counts.