shadcn.io is not affiliated with official shadcn/ui
Star Distribution Testimonials Block for React
A 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.
Installation
Overview
A rating shown as a shape, in a testimonials block for React with Base UI. A compact header (How owners rate Alcove shelving, a fictional product) carries a Shine Button that reads "Read all 600 reviews", the number worked out from the data. Below it one framed figure, drawn with hairlines and + marks on its corners, holds three cells that share their lines: the average with partial stars, the review count and a verdict worked out from the data ("Most gave 5 stars"); one owner's quote; and, spanning both rows beside them, five columns standing on a baseline from one star to five, each as tall as its share of the reviews and topped with its count, with a dashed line marking where the average falls. Stars and columns are foreground tones, so the Shine Button is the block's only primary control. Columns rise from the baseline once and nothing moves with reduced motion. The score, the heights and the marker's position are all derived from the counts in the file, and the chart has a text alternative and a hidden table of the same numbers. It's built from Avatar, Guides and Shine Button, with Lucide stars, CSS transitions only and your theme's tokens. It stands vertical, where the call-to-action version is a list of horizontal bars. For product pages, app listings and landing pages that want the shape of the reviews as proof.
FAQ
How do I use my own review numbers?
Edit COUNTS at the top of the file: the number of reviews at one, two, three, four and five stars, in that order. The total, the average (to one decimal, by integer maths), the column heights, the marker position and the verdict are all derived. Only put real review numbers here.
How is the average marker placed?
The five columns share the width equally, so the centre of the one-star column is 10 percent in and each next column is 20 percent further. The marker sits at the exact average on that scale, not the rounded one, so 4.3 stars lands a little past the four-star column's centre. The plot is always read left to right, as a number line, including in right-to-left pages.
Where does the verdict come from?
It is computed from the counts. "Most gave 5 stars" only appears when more than half of the reviews share the top rating; otherwise the line reads "The most common rating is N stars", so the claim is always true for your data.
How do screen readers read the chart?
The chart is one image with a name built from the data: every count and the average, in words. The columns and axis are hidden from assistive technology, and a visually hidden table lists the same counts for anyone who wants to move through them. The score is read as "Rated 4.3 out of 5". The partial stars, the frame and the + marks are decoration and hidden.
Do small counts disappear?
The tallest column fills most of the plot and the others scale from it, so a tiny count is a thin but visible column with its value above it. Heights are whole percentages of the plot, and the value is always printed, so the number never depends on reading the height.
How does it look on a phone?
The three cells stack in reading order: the score and verdict, then the quote, then the chart, so the quote is on the first screen. The columns narrow to fit while the values stay at full size, and at 320 pixels the five columns and their labels still fit without scrolling.
Related
- Pro
Rating Breakdown Testimonials
Ratings and reviewsA 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.
- 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
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
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
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.
- Pro
Centered Star Rating Hero
TestimonialsA showcase centered hero led by its review score, with five stars and the average, a Shine Button, review-site badges and three reviews below in cells whose hairlines overshoot their corners.