shadcn.io is not affiliated with official shadcn/ui
Community Aggregate Reviews Block for React
One rating pooled from three channels of a camera maker: a cell per channel with an include checkbox, and five pooled distribution rows stacked by channel with weights of 100, 60 and 30.
Installation
Overview
A pooled rating for React with Base UI, for the Linnbridge M3, a fictional mirrorless camera sold through the maker's shop, partner shops and talked about in an owners' forum. A header says how many reviews there are and where from. A split under a rule follows. At the start, one cell per channel with overshoot lines: a tone key, its name, its average beside read-only stars, its review count, how much one of its reviews weighs ("Counts in full", "Counts at 60%", "Counts at 30%") and a checkbox, "Include in the average". At the end, the pooled score as a rolling figure and five distribution rows, each bar stacked by channel in three tones of your theme's text colour. Untick a channel and its part of every bar closes, the shares and the average are worked out again, and a polite sentence says what is counted; the last channel stays on. On a phone the three cells become a sideways row you can swipe. Fifteen typed counts drive everything; each row's share is by the largest remainder method. It's built from Checkbox, Field, Rating, Sliding Number and Guides, with CSS transitions only.
FAQ
How do I use my own channels?
Edit CHANNELS at the top of the file: for each channel an id, a name, a note, a tone, a weight out of 100 and its review counts by star, five stars first. Each channel's average (in tenths, by whole-number maths), the pooled average, the weighted rows and their shares are worked out when the module loads. A pooled review counts as its channel's weight over 100: a shop review as 1, a partner-shop review as 0.6 and a forum post as 0.3. The weights here are example figures.
What do the checkboxes do?
They take a channel in or out of the pool. The pooled score, the rows and the "reviews count after the weights" line follow at once. The last ticked channel is disabled, so the pool is never empty. The whole cell is the checkbox's label, so a click anywhere in it toggles it, and the box is named by the channel and "Include in the average".
The Checkbox takes checked and onCheckedChange(checked); the label points at it with htmlFor.
How do I read a stacked bar?
Each row is one star rating. Its length, against the longest row with every channel in, is the weighted count of that rating; inside it, each channel's part is as long as its weighted reviews, in the tone shown in the channel's cell. The number at the end is the row's share of the pool. The bars are drawn only; the shares and the pooled average are in text and in a polite status line.
Why are the parts different greys, not colours?
The three tones are your theme's text colour at three strengths, so the chart works in every preset and keeps the page's primary colour for its call to action. Each channel's cell carries the same tone as a small square key, and a channel taken out loses its part and is tinted, with its state in the checkbox.
Related
- Pro
Verified Toggle Reviews
Score summariesA review summary with a Verified purchases only switch: the average, the count, the share rated four or more and five distribution rows are worked out again, with a delta line against all reviews.
- Pro
Rating Breakdown Reviews
Score summariesA review summary for a carry-on suitcase whose star rows filter the reviews: the average, the count, the share that would recommend it and a five-row distribution, beside the four most helpful reviews with a Helpful vote each.
- Pro
Distribution Bars Reviews
Score summariesA rating distribution for a hiking boot: five ruled rows of bars, counts and shares, a Bars and Table switch, and a readout of mean, median, mode and the share rated four or more.
- Pro
Star Threshold Histogram Reviews
Score summariesA star-rating threshold for a lambswool blanket: a Slider sets the lowest rating that counts, a bracket spans the rows it keeps, and a reading panel gives the share that clears it and the newest review that does.
- Pro
Trust Badges Testimonials
Ratings and reviewsA scoreboard of four review sources for a bookkeeping app: a weighted average beside the heading, then a band of four cells on shared hairlines, each with a score, partly filled stars, its review count, one reviewer line and a link.
- Pro
Rating Stars Awards
Rankings and scoresFour review sites as four cells with overshoot, each with read-only stars, the rating in words, the review count and a link, and a footnote that writes out the weighted average of the four.