Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Helpful Votes Reviews Block for React

The best favourable and the best critical review of a water filter jug side by side, each with a Helpful vote and a worked-out 'n of m found this helpful', above the other reviews in ruled rows with a most-helpful or newest order.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A helpful-votes section for React with Base UI, for the Wherstead Slim Pitcher, a fictional water filter jug. A start-aligned header sits over two cells that share one hairline: the most helpful review among the four and five stars and the most helpful among the one and two stars, each with its stars and their value in words, a title, the text, the reviewer, a fixed date, a Helpful toggle and the sentence "64 of 71 found this helpful". Under a rule, the other three reviews are ruled rows with a sort group, Most helpful or Newest, that re-orders only when you press it. Both picks, the order and every figure come from the typed votes at the top of the file. It uses Toggle, ToggleGroup, Rating, Avatar and Guides, with CSS transitions only. On a phone the pair stacks, so the first review starts well inside the first screen.

FAQ

How are the two featured reviews chosen?

By the votes in REVIEWS: the review with the most helpful votes among those rated 4 or 5 is the favourable pick, and the one with the most among those rated 1 or 2 is the critical pick, ties broken by id. Swap the data and the cells follow. The other reviews fill the rows underneath, so no review appears twice.

What does pressing Helpful do, and is it saved?

It's a real toggle with aria-pressed. Pressing it adds one to the helpful count and one to the number of readers who voted, so "64 of 71" becomes "65 of 72"; pressing it again takes both back. A polite status line says "You marked this review helpful" or "Vote taken back". Nothing is sent and a reload starts afresh: to keep votes, post the review's id from the handler and seed helpful and asked from your data.

Why doesn't the order change when I vote?

Order is read from the votes the page loaded with, and only the sort group re-orders. A row that jumped to the top under your pointer the moment you voted would be hard to follow, so your own vote moves the count and nothing else. The line beside the group says which order the rows are in and is read out when it changes.

Why are the stars hidden from screen readers?

They're the catalog Rating, read-only, inside an inert, aria-hidden wrapper: they only draw the value, and the words next to them say it ("4 out of 5"). Rating draws in your warning colour by default; here it takes text-foreground, so the stars and the pressed controls stay in your theme's text colour.

Does it work right to left?

Yes. The cells and rows lay out with logical classes, so the reviewer sits at the start of each row; the counts, the "64 of 71" sentence and the dates are each wrapped so their digits stay in order, and the stars mirror.

  • Pro

    Upvote System Reviews

    Votes and replies

    Six reviews of a board game as cards with an Up and Down pill and a net score worked out from the votes, tabs for Top, New and Controversial, and a collapsible that folds reviews at a net of minus three or lower.

  • Pro

    A 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

    Twelve reviews of an interior paint as accordion rows: stars, title, excerpt and byline when closed; the whole review, a Helpful vote and the seller's reply when open.

  • Pro

    Masonry Layout Reviews

    Cards and walls

    Twelve reviews of pruning shears as cards of every length in CSS columns, with a star filter, an order switch, a polite count and a Helpful vote on each card.

  • Pro

    Top Rated Testimonials

    Ratings and reviews

    Four 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

    Emoji Reactions Reviews

    Votes and replies

    Four skateboard reviews that each take six reactions from a popover of toggles with counts, show their top three beside a total, and feed a ranking of the product's reactions beside them behind a divider.