Honest Rating

Shows how many reviews stand behind a star rating and how they split, so a 5.0 from three reviews doesn't look as solid as a 4.6 from 900.

StopsTrusted a 5.0 from three reviews

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/honest-rating.json

The files land in your project. They're yours to edit.

Usage

honest-rating-usage.tsx
import { bayesianScore, HonestRating, ratingStats, type RatingDistribution } from "@/components/ui/honest-rating"

<HonestRating key={picked} distribution={products[picked].distribution} onSelectStars={setFilter} />

What it catches

  • Ratings backed by very few reviews, with a likely range for the true score
  • Polarised splits hidden by an average
  • Sorting by raw average: a Bayesian score (IMDb-style) is offered instead
  • Optional link to read the low reviews first

Props

HonestRating props
PropTypeDefault
distribution* (required)

Review counts for 1★ to 5★.

RatingDistribution—
minReviews

Below this many reviews the score is flagged as a tiny sample.

number10
prior

Prior for the sorting score; pass your catalogue's mean.

RatingPriorDEFAULT_PRIOR
onSelectStars

Called when a star row (or "Read the 1★ reviews") is chosen, to filter the reviews below.

(stars: number) => void—
countText

Templates: `{count}`, `{low}`, `{high}`, `{one}`, `{five}`, `{score}`, `{mean}`.

string"from {count}"
smallSampleText

Shown when the review count is below minReviews.

string"Only {count}: the real score could be anywhere from {low…
polarizedText

Shown for a love-it-or-hate-it split.

string"Split opinions: {one} gave 1★ and {five} gave 5★. The av…
adjustedText

Explains the Bayesian sorting score.

string"Ranked as {score} when sorting, pulled toward {mean} unt…
readLowLabel

Button text to read the 1-star reviews.

string"Read the 1★ reviews"
emptyText

Shown when there are no reviews.

string"No reviews yet"

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Breakdown is a labelled list with text labels for each star level
  • The likely-range bar is role=img with an aria-label stating the range
  • Warnings are in a polite live region with text, not only icons
  • Star filters are real buttons, disabled when a level has no reviews

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

  • Statistics assume reviews are genuine; it does not detect fake or incentivised reviews
  • The prior and weight you pass change the Bayesian score; defaults may not suit your catalogue
  • The likely range is an approximation (Dirichlet, 90%), not an exact interval

What it stops

Trusted a 5.0 from three reviews

Also known as

star rating · reviews · ratings · bayesian average · product page · flipkart · amazon · sort by rating

Field type

Dependencies

Pairs well with