shadcn.io is not affiliated with official shadcn/ui
Compact List Reviews Block for React
Twelve one-line reviews of a notes app as a real table with sortable column heads, a Select that mirrors the sort, and nothing to open.
Installation
Overview
A compact list of reviews for React with Base UI, for Gleangate, a fictional notes app. A start-aligned header states the count and the average (both worked out from the twelve typed reviews) and carries a Select at its end that orders the rows. Under it a real table runs from rail to rail beneath a rule with + marks: the rating as stars and a number, the title over a one-line excerpt, the reviewer with a verified mark, the date and the helpful count. Everything is visible and nothing opens. The Rating, Reviewer, Date and Helpful column heads are buttons that sort the same table and set aria-sort, and a polite line says which order is on. On a phone the Reviewer and Date columns drop and the rating becomes one star and a number. It's built from Select, Rating, Guides and the Button styles.
FAQ
How do I use my own reviews?
Edit REVIEWS at the top of the file: each entry has an id, the name, a rating from 1 to 5, an ISO date, a title, a one to three sentence body, verified and a helpful count. The count and the average in the header are computed from the array, so they follow your edits. Dates are fixed text, never computed from today.
How does sorting work, and is it announced?
Each of the four sortable column heads is a button inside its th. The first press sorts a column biggest first (names A to Z), the next reverses it, and the th carries aria-sort="ascending", "descending" or "none". The Select lists all eight orders and always shows the one in force, so the two controls stay in step. A polite status line, hidden from sight, says "Sorted by newest first." after every change. Ties fall back to the newest review, so the order never flickers.
Why is the table a native table?
It needs a caption, column headers with scope and aria-sort, and a column set that drops on a phone, and a plain table gives all of that the same way on every library. The scroll region around it is named and reachable by keyboard.
Related
- Pro
Paginated List Reviews
Lists and pagesTwenty-four reviews of a cookbook five to a page, with a page-size Select, the catalog pagination with ellipsis and a polite 'Showing 6 to 10 of 24'.
- Pro
Infinite Scroll Reviews
Lists and pagesTwenty reviews of a podcast app ten at a time in a fixed-height scroll region that appends five more at its end, with a Load more button, placeholder rows and a polite count.
- Pro
Accordion Expandable Reviews
Lists and pagesTwelve 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
Filter Sort Bar Reviews
Filter and searchA toolbar band for rain-jacket reviews: a rating Select, a Verified toggle, a date Popover and a sort Select, a live count with removable chips, and the matching reviews as ruled rows.
- Pro
Advanced Sort Reviews
Filter and searchA filter panel for tent reviews: a sort key, an order, star pills, a recency segment and a verified Switch beside the matching reviews, with removable chips, a live count and a bottom Sheet on phones.
- 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.